sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
c5bf064dfbf06425803f8b690b1e70926d92e378941b662224d0a67aa351ec70 | Python | 1,539 | 44 | from .voc0712 import VOCDetection, VOCAnnotationTransform, VOC_CLASSES, VOC_ROOT
from .tt100k import TT100KDetection, TT100KAnnotationTransform, TT100K_CLASSES, TT100K_ROOT
from .tt100k_45cls import TT100K45Detection, TT100K45AnnotationTransform, TT100K45_CLASSES, TT100K45_ROOT
from .coco import COCODetection, COCOAnno... |
566327df1889cbcb0532473fb2b99c70456d33440944b7f642554cf0ec7b53f5 | Python | 1,540 | 63 | from collections import defaultdict
from itertools import chain, combinations
from typing import Any, Dict, Iterable, List, Optional, Tuple
from oaklib.types import CURIE
def powerset(iterable):
"""
Calculate the powerset of an iterable.
>>> list(powerset([1,2,3]))
[(), (1,), (2,), (3,), (1, 2), (1,... |
776fa0814be4e1cf2c4d0a7f127ff25e06327ebc23576f0464689aa3537ba1e0 | Python | 1,540 | 44 | import argparse
import gzip
parser = argparse.ArgumentParser(description='Compare eQTLgen to MetaBrain')
parser.add_argument('eQTL_file',
help='File with eQTL data')
parser.add_argument('gwas_file',
help='File with gwas data')
parser.add_argument('outfile',
he... |
a9d2963180680e4804a2f8690f43fd3193d508cfddddf3e378874f93893382d4 | Python | 1,540 | 48 | """Tests for the Gilda annotator."""
import unittest
from oaklib.datamodels.text_annotator import TextAnnotationConfiguration
from oaklib.implementations import GildaImplementation
from tests import CELL_CORTEX
try:
import gilda # noqa: F401
HAS_GILDA = True
except ImportError:
HAS_GILDA = False
@uni... |
02021f3d0a774f42242a317b1aebd8c61a13306fcb4a2a607128c71dab1fe8e3 | Python | 1,543 | 57 | import os
import pprint
from pathlib import Path
ROOT = os.path.abspath(os.path.dirname(__file__))
INPUT_DIR = Path(ROOT) / 'input'
OUTPUT_DIR = Path(ROOT) / 'output'
SCHEMA_DIR = Path(ROOT) / '../src/linkml'
EXTERNAL_DB_DIR = Path(ROOT) / '../db' ## for integration tests: optional
def output_path(fn: str) -> str:
... |
1fb86cd10c79b29f9c2d3c135c7c75ac1ecf44471c99b6c22d8ed49b1bfc85fe | Python | 1,544 | 39 | # Copyright 2020 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... |
21f0af147ff0b8c667b5e8b8e59eb00847dec44482a507a43385895189badc38 | Python | 1,544 | 58 | import AFQ.api.bundle_dict as abd
from AFQ.tests.test_api import create_dummy_bids_path
from AFQ.api.group import GroupAFQ
import AFQ.data.fetch as afd
import pytest
def test_AFQ_custom_bundle_dict():
bids_path = create_dummy_bids_path(3, 1)
bundle_dict = abd.default18_bd()
GroupAFQ(
bids_path,
... |
5033322aa9de81b7ec4afaae8c16d8e1aa65c9bf8beefd7dcb2f7bf25688234f | Python | 1,544 | 69 | """Math utils functions."""
import torch
def cosh(x, clamp=15):
return x.clamp(-clamp, clamp).cosh()
def sinh(x, clamp=15):
return x.clamp(-clamp, clamp).sinh()
def tanh(x, clamp=15):
return x.clamp(-clamp, clamp).tanh()
def arcosh(x):
return Arcosh.apply(x)
def arsinh(x):
return Arsinh.a... |
516a68bf884c6ad754fef959734ae1e09d8f6a7522dc0eec805e1f78616585dc | Python | 1,545 | 46 | from pathlib import Path
from os import chdir
import unittest
from nipype.interfaces.base import CommandLine
from qipype.commands import NewImage, Diff
from qipype.fitting import Multiecho, MultiechoSim
vb = True
CommandLine.terminal_output = 'allatonce'
class Relax(unittest.TestCase):
def setUp(self):
P... |
5971c1cf4ecf8cd1c7a13d5e3ef876df31e2ededcb5251d305ebd572b97a902b | Python | 1,545 | 45 | import json
import os, errno
import sys
import time
import shutil
import subprocess
from subprocess import Popen, PIPE
def parse_and_format_final_params(content):
content = content.replace("Final best parameter configuration:", "")
content = content.split(',')
content = map(str.strip, content)
content ... |
8c126ff4254722bff9a7b2b4f07a5b50b1008415c41593b056d787c7b75c1644 | Python | 1,545 | 37 | # functions/add.py
import torch
from torch.autograd import Function
from .._ext import roi_crop
from cffi import FFI
ffi = FFI()
class RoICropFunction(Function):
def forward(self, input1, input2):
self.input1 = input1
self.input2 = input2
self.device_c = ffi.new("int *")
output = to... |
f24fd74b94898bbc982a1a6f0878c95da6700a1196e3b36551ff10d2e6400fdc | Python | 1,546 | 45 | #!/usr/bin/env python
# Copyright 2015 Minhua Wu
# Apache 2.0
# convert acronyms in swbd decode result to fisher convention
# e.g. convert things like en_4156 B 414.26 0.65 u._c._l._a. to
# en_4156 B 414.26 0.16 u
# en_4156 B 414.42 0.16 c
# en_4156 B 414.58 0.16 l
# en_4156 B 414.74 0.17 a
from __future__ import d... |
2e5b4a628db99d31fb8c4de02ca9d21f7b867fda687d3aa4d76ff217f00993ad | Python | 1,548 | 58 | #!/usr/bin/env python
# coding: utf-8
# Evaluation: Transformer Dose Calculation
## Import libraries and define auxiliary functions
import h5py
import json
import numpy as np
import sys
sys.path.append('../src')
from models import dota_energies
from preprocessing import DataRescaler
from evaluation import time_analys... |
e5b204bf7b6828dde3819beebdc79eba29cda51aa2f63b07cc2c234dd7493a45 | Python | 1,549 | 46 | import math
import random
import re
import sys
import numpy
import torch
import torch.nn as nn
import torch.nn.functional as F
from utils.param_remap import remap_for_paramadapt
from .derive_blocks import derive_blocks
class BackBone(nn.Module):
def __init__(self, config, is_training=True):
super(BackBo... |
b72130e822228649f9f702d3ceec5762e721854c6f5b2a5013437c2ee14a09c4 | Python | 1,550 | 44 | hydropathy = { # Kyte J, Doolittle RF (May 1982). "A simple method for displaying the hydropathic character of a protein". Journal of Molecular Biology. 157 (1): 105–32. CiteSeerX 10.1.1.458.454. doi:10.1016/0022-2836(82)90515-0. PMID 7108955.
"A" : 1.8, "G" :-0.4, "M" : 1.9, "S" :-0.8,
"C" : 2.5, "H" :-3.2, "N... |
c5f0c4d912b85d05e53712be40dfc1d048152db4e72101af617e4b3e2ba3f768 | Python | 1,550 | 43 | # encoding: utf-8
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.checkpoint import checkpoint
from backbone.derived_backbone import BackBone
from head.ASPP_Sep import ASPP_Sep
from seg_opr.seg_oprs import AttentionRefinement, ConvBnRelu, FeatureFusion
class DeepLabV3(nn.Module):... |
223d079704a40d2ed16bb331ddfd7d7035a914465f6b78e985764e6e5df8d859 | Python | 1,551 | 42 | # Copyright 2022 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... |
74cea55a30da250c96da0dba9191c786e205f81f24da3b68a4ddae70a1285c00 | Python | 1,551 | 37 | # Copyright 2020 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... |
c919012d73c98b06396f119633de7c091aa2e440611d15316ee6df282b8887a2 | Python | 1,551 | 47 | """Phase 2 regression tests for the AIF agent."""
import numpy as np
from mb_dual_dan.connectome import extract_mb, load_winding
from mb_dual_dan.models.aif_agent import AIFAgent
from mb_dual_dan.tasks.conditioning import conditioning_trials, make_cs_pair
def _train(n_trials: int = 60, seed: int = 0):
c = load_... |
ea28455b261f05a91c80da6d8875c69a2f6e1ff537177a618b0dc28d2a9bfe05 | Python | 1,551 | 44 | import re
import numpy as np
import pandas as pd
def loadFile(path, headers=None):
'''
This function will parse a standard HEKA .asc file into a pandas dataframe.
Arguments:
path - a stringIO input of a standard HEKA output .asc file.
Returns:
df, dfcache - two copies of the file reformatted... |
3a1b17894b96752887ffa5e3b1a2c26aeae4ee6f015b783c0cf6cbb9ff7909bb | Python | 1,552 | 64 | import torch
import torch.nn as nn
import torchvision
import torchvision.transforms as transforms
import os, random, sys, math
import numpy as np
import matplotlib.pyplot as plt
import networks
device = 'cuda'
batch_size = 25
Z = 128
T = 1
transform_train = transforms.Compose([
transforms.ToTensor(),
])
trainset... |
817d2ae8e4f80ae48fc18320fb8c6379afd1efc8b90077eac0289caa27e97ada | Python | 1,552 | 67 | import pickle
import argparse
import matplotlib.pyplot as plt
import numpy as np
from ezephys import stimtools
# PARSE COMMANDLINE ARGUMENTS
parser = argparse.ArgumentParser()
parser.add_argument(
'output',
help='Path to save output. '
'Pickled dict with ser_input and gaba_input as attributes.',
)
pars... |
145f4a1de43ba2643f9ed3c1680143aadc21901d617bd315d9e2da5e50311d45 | Python | 1,553 | 41 | import torch
from .dropped_model import Dropped_Network
class SSDLite_Dropped_Network(Dropped_Network):
def __init__(self, super_model):
super(SSDLite_Dropped_Network, self).__init__(super_model)
self.extra = super_model.extra
def forward(self, inputs):
net_sub_obj = torch.tensor(0.,... |
3d78f37819ca5a0ca5f09ddf2bf659f326b27029a872fd9a753bad2289004050 | Python | 1,553 | 39 | import pickle
import scanpy as sc
import pandas as pd
import os.path
import sys
import os
sys.path.append('../../LassoVariants/AlternateLasso')
count = 0
pcount = 0
ccount = 0
for file in ['output/scobj/BICCN2_gene_id_order_gene__sparse_mat_2C6_1000_scobj.pyn',
'output/scobj/BICCN2_gene_id_order_gene__sparse_mat_... |
4f6005ef2d75cbc8af36171d4e367256ba10d8104287eac2bd8af91c24fd7a0f | Python | 1,553 | 42 | import argparse
import os
from PIL import Image
def resize_image(image, size):
"""Resize an image to the given size."""
return image.resize(size, Image.ANTIALIAS)
def resize_images(image_dir, output_dir, size):
"""Resize the images in 'image_dir' and save into 'output_dir'."""
if not os.path.exists(o... |
68b9f1fd25e16b587c643c1c93cd58aebeb791fe3f8ac07886aed5f6b6a90590 | Python | 1,553 | 66 | # type: ignore[attr-defined]
from typing import Optional
from enum import Enum
from random import choice
import typer
from rich.console import Console
from tmkit import version
class Color(str, Enum):
white = "white"
red = "red"
cyan = "cyan"
magenta = "magenta"
yellow = "yellow"
green = "g... |
dc0db1d101ee3f31aa0ee482aeaa08d139da554b31db06862bb7a07dd942c336 | Python | 1,553 | 55 | import torch
import torch.nn as nn
import numpy as np
import matplotlib.pyplot as plt
# Hyper-parameters
input_size = 1
output_size = 1
num_epochs = 60
learning_rate = 0.001
# Toy dataset
x_train = np.array([[3.3], [4.4], [5.5], [6.71], [6.93], [4.168],
[9.779], [6.182], [7.59], [2.167], [7.042]... |
3da8234520c0601a9e3a75581638f869d34543278339fd0e1765375c69a8a18e | Python | 1,558 | 63 | import random
import networkx as nx
import matplotlib.pyplot as plt
from graphxai.utils import khop_subgraph_nx
house = nx.house_graph()
base_graph = nx.barabasi_albert_graph(n=10, m = 1)
# Choose pivot:
nx.set_node_attributes(house, 1, 'shape')
nx.set_node_attributes(base_graph, 0, 'shape')
to_pivot = random.choi... |
95b28fe5eaa8829ce11a5a09e986cbb731d50fa4f9ec92371a8947370b60dcb7 | Python | 1,558 | 57 | import os
import torch
from M2TR.datasets.dataset import DeepFakeDataset
from M2TR.datasets.utils import (
get_image_from_path,
get_mask_path_from_img_path,
)
from M2TR.utils.registries import DATASET_REGISTRY
'''
DATASET:
DATASET_NAME: FFDF
ROOT_DIR: /some_where/FF++/face
TRAIN_INFO_TXT: '/some_where/... |
c1b5a108e9f964460256e1f0ef2ba1b81ba589fbfc2c8ef21e329b5fc85bc000 | Python | 1,558 | 60 | import os
import pandas as pd
import matplotlib.pyplot as plt
from pathlib import Path
def getdata(data_path, ext):
files_list = []
files = os.listdir(data_path)
for file in files:
if file.endswith(ext):
files_list.append(file)
return files_list
def splitdata(data_list):
train... |
f1bb6e3f823db889bef09e22475ea65cbf8e02fe05f39af1257bd4a5347ebb6a | Python | 1,558 | 61 | """Snakemake wrapper for bwa sampe."""
__author__ = "Julian de Ruiter"
__copyright__ = "Copyright 2017, Julian de Ruiter"
__email__ = "julianderuiter@gmail.com"
__license__ = "MIT"
from os import path
from snakemake.shell import shell
# Extract arguments.
extra = snakemake.params.get("extra", "")
sort = snakemak... |
393bdd6c950f3ed4b793f4e9567b81b69549f768abd2d6dbad463fc5ed7c603f | Python | 1,559 | 64 | import torch
import torch.nn as nn
import torchvision
import torchvision.transforms as transforms
import os, random, sys, math
import numpy as np
import matplotlib.pyplot as plt
import networks
device = 'cuda'
batch_size = 25
Z = 128
T = 1
transform_train = transforms.Compose([
transforms.ToTensor(),
])
trainset... |
3c96984bd3187854a039306ffa1ddd5cd7e20bb8b99b702a2b1669872ef65648 | Python | 1,559 | 47 | # Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma de
# Barcelona (UAB).
#
# This work is licensed under the terms of the MIT license.
# For a copy, see <https://opensource.org/licenses/MIT>.
import unittest
import carla
class TestVehiclesSpawnTest(unittest.TestCase):
def test_vehicle_... |
2685c6248867bcf105f401e043fc2139b0018b599f75c59cb581b689fc4d7748 | Python | 1,560 | 49 | __author__ = "Johannes Köster"
__copyright__ = "Copyright 2019, Johannes Köster"
__email__ = "johannes.koester@uni-due.de"
__license__ = "MIT"
import tempfile
from snakemake.shell import shell
species = snakemake.params.species.lower()
release = snakemake.params.release
type = snakemake.params.type
log = snakemake.l... |
a558b56001e24eb1e604ca0a95de776403342115766b25ed61efd702adb7f654 | Python | 1,560 | 32 | """mi_groups.py GRAB.png OUTPREFIX [x0]: split a material instance editor grab into one PNG per parameter group.
GRAB.png is an xwdgrab.py capture of the material instance editor window; x0 is where the Details panel starts
(default 580 for a 1400 px wide window with the viewport on the left). Group headers are found ... |
cf5e22725d66b0da1845e922440c8bff0c1d2203c40a9f9ddb08860bb0bc4dfe | Python | 1,561 | 24 | """Log get_telemetry_data during a hard launch, a lane-change steer and a hard stop (Town10HD_Opt spawn 79)."""
import carla, json, sys, math
c = carla.Client('localhost', 2000); c.set_timeout(60); w = c.get_world()
sp = w.get_map().get_spawn_points()[79]; sp.location.z += 0.2
orig = w.get_settings(); s = w.get_setting... |
51998f73d42a778a4a6311da86498e8ead599757f24fa23dabfe51ac35978f16 | Python | 1,563 | 57 | import os
# ----------------------------------------------------------------------------
class Protocol():
""" Defines the protocol class to get parameters from a text file.
"""
def __init__(self, filename):
""" Constructor.
INPUT :
-----
filename : str, path to the protoc... |
9ca556c7c5e1e51e777d3dc3ba6b46fc52bc3c0c2d1bc80597fbcc6b94466ac9 | Python | 1,563 | 51 | # -*- coding: utf-8 -*-
"""
@author: satohara
"""
import sys
sys.path.append('../')
import numpy as np
from sklearn.datasets import fetch_20newsgroups
from sklearn.feature_extraction.text import TfidfVectorizer
from EnumerateLinearModel import EnumLasso
# data
categories = ['comp.sys.ibm.pc.hardware', 'comp.sys.mac.... |
1e2ec5e2f6c05e54c52bdf6598692d9d256e93b989bbddfbeff68a1651da5ef1 | Python | 1,564 | 64 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 24 18:57:36 2021
@author: spiros
"""
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
plt.rcParams.update(
{
"text.usetex": False,
"font.size": 18,
}
)
mpl.rcParams["axes.spines.right"] = False
m... |
e6422ee0eefa997bb395056ab9f5f74bd533397101374521a7b67f5483657e0c | Python | 1,565 | 65 | """Train an HMM on amplitude envelope data.
"""
from sys import argv
if len(argv) != 3:
print("Please pass the number of states and run id, e.g. python 1_train_hmm.py 8 1")
exit()
n_states = int(argv[1])
run = int(argv[2])
#%% Import packages
import pickle
from osl_dynamics.data import Data
from osl_dynami... |
f099db6f8c3935c1157d59dcfec7c4e2cc235f313566a18ebd903cfe9aa2588b | Python | 1,565 | 47 | import logging
import unittest
from collections import Iterator
from linkml_runtime.dumpers import yaml_dumper
from oaklib.implementations import SqlImplementation
from oaklib.implementations.pronto.pronto_implementation import ProntoImplementation
from oaklib.omk.omk_mapping_utils import unreciprocated_mappings, calc... |
28756ba8b18b2053f123defbdcece03494ff5aa35d8d269880549d51899680c7 | Python | 1,567 | 45 | #%%
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
from pymaid_creds import url, name, password, token
from data_settings import data_date_A1_brain, pairs_path
import pymaid
rm = pymaid.CatmaidInstance(url, token, name, password)
from contools import Celltype, Celltype_An... |
fd935d222479066701c2ac39f0d30e741078371a3583bb4493f46bb9c7d4b465 | Python | 1,567 | 50 | ## System
import os,gc
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' # no debugging from TF
os.environ['TF_CPP_MIN_VLOG_LEVEL'] = '3'
## Plots
import matplotlib
# matplotlib.use('Agg')
import matplotlib.pyplot as plt
import matplotlib.colors as colors
import seaborn as sns
import scanpy as sc
## siVAE
# Util
from siVAE... |
2aa9d94c2e3e69dcef8304a0b546b6d9685b662dae51ecbb28ec10a26ce6f0df | Python | 1,568 | 56 | import unittest
from sssom_schema import Mapping
from oaklib import get_adapter
from oaklib.datamodels.vocabulary import IS_A, PART_OF, SEMAPV, SKOS_EXACT_MATCH
from oaklib.utilities.mapping.mapping_validation import validate_mappings
from tests import CYTOPLASM, FUNGI, INPUT_DIR, NUCLEUS, OUTPUT_DIR, VACUOLE
DB = I... |
4a6e63d7c6ce47e5b7ebd3220605882b9691c0d580c21ea74085649c7a863642 | Python | 1,569 | 55 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Module containing functions useful for python scripts.
Created on Thu Nov 1 16:03:09 2018
@author: nicolas
"""
class Arguments:
"""
Container object that stores arguments through its attributes.
Useful for simulating command line arguments passed to... |
4428d7ee590c5dc0175f8175697f688703043eb9208f3b7a1a6eb5a795385d0b | Python | 1,571 | 33 | ####################################################################################################
# Copyright (c) 2019 - 2023, EPFL / Blue Brain Project
# Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch>
#
# This file is part of VessMorphoVis <https://github.com/BlueBrain/VessMorphoVis>
#
# This program is free ... |
6c3a80ee175414c375bb877d28b3ceb5b2e7e02bf9167921c791f365a6bb00b6 | Python | 1,571 | 39 | # %%
# identify clusters with higher than 2*std mean axonic IO or dendritic OI
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
from pymaid_creds import url, name, password, token
from data_settings import data_date, pairs_path
import pymaid
rm = pymaid.CatmaidInstance(url, ... |
282c3faed77b8a97b11759dcb8b0fccdfe379b0b5885d4b924bd6b4c36d5b586 | Python | 1,572 | 41 | import argparse
import numpy as np
import pandas as pd
from voronoi import Voronoi
parser.add_argument('--Nx', type=int, default=13)
parser.add_argument('--Ny', type=int, default=13)
parser.add_argument('--shape', type=str, default='hex')
parser.add_argument('--notchWidth', type=int, default=4)
parser.add_argument('--... |
8e82c8b69b981236d6f4c969bc54abdcca7e359b1823de5dbb0b2d18476344d4 | Python | 1,573 | 59 | #!/usr/bin/env python
# Copyright 2018 Johns Hopkins University (Author: Aswin Shanmugam Subramanian)
# Apache 2.0
# Works with both python2 and python3
# This script assumes that WPE (nara_wpe) is installed locally using miniconda.
# ../../../tools/extras/install_miniconda.sh and ../../../tools/extras/install_wpe.sh
#... |
99452706caac8d42649f51a050ac24b50553dc6ca3e5e442c4961f98980e50ff | Python | 1,573 | 65 | # %%
import scanpy as sc
import scanpy.external as scex
import numpy as np
import pandas as pd
from glob import glob
import os
from params import *
from matplotlib.pyplot import rc_context
from converting_anndata import *
from warnings import filterwarnings
filterwarnings("ignore")
sc.settings.verbosity = 3
def... |
0e6e16113604e7a0ed8fa1f44451ee50dec19be3520eb0b6cf5c66c39b93c952 | Python | 1,574 | 66 | __author__ = 'jieqing jiao'
__email__ = "jieqing.jiao@gmail.com"
# weighting scheme implementation based on https://www.ncbi.nlm.nih.gov/pubmed/16912378
import numpy as np
from . import kt
def get_weight(dt, isotope='18F', a=1, t=None, r=None, tac=None):
if isotope == '12C':
half_life = 20.39 * 60
... |
a16143ae2547a30320102bf3f7456a374e0af675e6527915e29c71e988228a60 | Python | 1,575 | 55 | #!/usr/bin/env python3
# Copyright 2020 Xuechen LIU
# Apache 2.0.
import os
import re
import sys
MAX_MICID = 15
def _split_utt_from_wav(wav_name, mic_id, mode):
wav_pathname = os.path.splitext(wav_name)[0]
if mode == 'sc':
return re.sub(r'{}', str(mic_id).zfill(2), wav_pathname)
else:
ret... |
d6578acfb232b87e1cb03a5684e840802a9ba8f5ebf01efe07fed773e3f5db70 | Python | 1,575 | 45 | import argparse, os
class BaseOptions():
"""This class defines options for training, testing and prediction"""
def __init__(self):
self.initialized = False
def initialize(self, parser):
self.initialized = True
parser.add_argument('--check_consistency', action='store_true', req... |
22ac2df7c8cac7affd80e8ada5b44c30406523208a44ca5422fd33a36d1417df | Python | 1,576 | 42 | from typing import List, Optional
import torch
import torch.nn as nn
class MultiLabelLoss(nn.Module):
def __init__(
self,
regularization: bool = True,
l: float = 0.1,
intervals: Optional[List[int]] = None,
):
super().__init__()
reduction = "none" if intervals e... |
953ac15b7fcb098fdc0c3198c2df97e4566b81dc4914a134cb86a8a8801b654f | Python | 1,576 | 40 | import platform, sys, logging
def log_metadata_and_start_message(num_processes, logger):
python_version = "Python " + sys.version
os_info = platform.platform()
pc_name = platform.node()
logger.info(python_version)
logger.info("%s %s", pc_name, os_info)
if num_processes > 1:
logger.info... |
8267a2d7ab26ed0e7b2eba14873e81985986fc35c7b40798605d7d0b9f21307b | Python | 1,577 | 53 | import torch.nn as nn
import torch
from utils.config_utils import parse_net_config
from .operations import OPS, conv_bn
class Block(nn.Module):
def __init__(self, in_ch, block_ch, ops, stride, dilation=1, use_se=False, bn_params=[True, True]):
super(Block, self).__init__()
layers = []
fo... |
c9fbcf9ab80a1406ba9c52d63880252a1fda78ae3eef8bc91c643505987c7aa0 | Python | 1,577 | 53 | """code to explore Matlab files"""
import time
import numpy as np
import scipy.io
def explore(mat, tab_count=0, skip_meta=True):
tabs = ' ' * tab_count
if type(mat) == dict:
for k in mat.keys():
if not skip_meta or not k.startswith('_'):
if isinstance(mat[k], (bytes, str... |
ef05284c24fd77993f7ece4fbed9bf48ee95f868e90820cceda619bae22b7c56 | Python | 1,577 | 43 | """
The `utils` module contains classes and methods that provide
more general utilities that are used across the package. Most of this
functionality cannot be appropriately confined to just one module, and
thus is included here.
"""
from .utils import _is_lua_trained_model
from .utils import get_indices_and_probabilit... |
3c8ba7044961fe053018830c9dbf028bcc173ea50002deb5cf73e21cb6b4c1e8 | Python | 1,578 | 66 | """Train an HMM on time-delay embedded/PCA data.
"""
from sys import argv
if len(argv) != 3:
print("Please pass the number of states and run id, e.g. python 1_train_hmm.py 8 1")
exit()
n_states = int(argv[1])
run = int(argv[2])
#%% Import packages
import pickle
from osl_dynamics.data import Data
from osl_d... |
936c87af86f8e2d4262b09e188d7c9ac0aa8698a066a570d4a4374be1701cf18 | Python | 1,578 | 44 | import logging
from pathlib import Path
import numpy as np
import pandas as pd
from spotipy.utils import points_matching
from stardist.models import StarDist2D
from tqdm import tqdm
from cenfind.core.data import Dataset
from cenfind.core.detectors import extract_nuclei
from cenfind.constants import datasets
PREFIX_R... |
7893ad531345bb24b446e8fcbbd51337d05c2387fed9afd20e4967171de3f3fa | Python | 1,579 | 28 | # This script is part of navis (http://www.github.com/schlegelp/navis).
# Copyright (C) 2018 Philipp Schlegel
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of... |
9acdd55ca132db7f39dcfe4ed8ed2bb181b5ff3ede78ba37384adafadd3832de | Python | 1,579 | 40 | # requires: mayavi
# dataset: mne_sample
"""Create a HTML report file for a permutation test of source space data"""
import eelbrain as e
# settings
n_samples = 1000
# Load data
ds = e.datasets.get_mne_sample(tmin=-0.1, tmax=0.2, src='ico', sub="modality=='A'")
# compute distribution of max t values through permu... |
aa5a590190b46f8b8615038dee73f0e67ad182e186f5695e2424dfefa444177b | Python | 1,581 | 47 | import numpy as np
from sklearn.neighbors import kneighbors_graph
def embedding_matrix_2_kNN(X, k, mode='connectivity', sentence_to_articles=None):
"""
:param X: the embedding matrix called C in the paper
:param k: number of nearest neighbours
:return: graph of the nearest neighbours
:Example:
... |
cc803380cef087e9a5756a53a3810aed33cd0daa38c05a52c36ca8c956cc6ef5 | Python | 1,581 | 49 | from abc import ABC
from typing import Iterator
from oaklib.datamodels.text_annotator import TextAnnotation, TextAnnotationConfiguration
from oaklib.interfaces import SearchInterface
from oaklib.interfaces.basic_ontology_interface import BasicOntologyInterface
TEXT = str
class TextAnnotatorInterface(BasicOntologyInt... |
1bd867ef82ed92d0e0732d94495d20ff30ef2ec04581563fac06e41fd867183f | Python | 1,582 | 41 | # Copyright 2021 Google Research. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... |
2a23a72c066f408e92002ef624e9c3ea4f62fc6b84a33f1c18fafa86a9619de0 | Python | 1,583 | 56 | """
Title
-----
Frequency-current curve
Description
-----------
A frequency-current curve (F-I curve) is the function that relates the net
current ``I`` flowing into a neuron to its firing rate ``F``.
In this example we show:
- How to calculate the somatic F-I curve for a simple 2-compartment neuron model.
- How to ... |
3f7d8677f0df606e326061f252d1865caa66fc6951a3745e1b0caca75b266207 | Python | 1,583 | 44 | import logging
import unittest
from oaklib.datamodels.vocabulary import HAS_PART, IS_A
from oaklib.implementations.pronto.pronto_implementation import ProntoImplementation
from oaklib.resource import OntologyResource
from oaklib.utilities.graph.relationship_walker import walk_down, walk_up
from tests import INPUT_DIR,... |
abc1dd4fa49df0f1515d57dafcd33cea506d5bbd605d631f90970cc2f43e13ce | Python | 1,583 | 55 | #!/usr/bin/python
import os
import random
import sys
from scipy.interpolate import interp1d
input_file = sys.argv[1]
print "selected file %s \n" % input_file
with open(input_file, 'rb') as data_file:
lines = data_file.readlines()
wl_data = []
ua_data = []
us_data = []
# number of arguments
... |
11068d182569ad9e0ae4bb2185af93fd0c22c9524d1a77eb204097a97a5c4c07 | Python | 1,584 | 65 | # unmute when the error "libgcc_s.so.1 must be installed for pthread_cancel to work" came up
# import ctypes
# libgcc_s = ctypes.CDLL('libgcc_s.so.1')
from tkinter import N
from cell_detection import *
from spot_detection import *
from image_manipulation import *
from params import *
import pandas as pd
# from pylab... |
500984b4f810897e948f4361a426ac42314b4ca07b1023b84cd74c2fa8256b27 | Python | 1,584 | 53 | import numpy as np
import torch
def convert_image(sample):
# convert input data to correct type
image = np.ascontiguousarray(sample['image'], dtype=np.float32)
# turn it into a torch tensor, and unsqueeze dim=0 to add a dim for
# the channels (of which we only have one:densities)
image = torch.fr... |
1aeac74dd50093f33e04a008876f77e200de00148a390e6b49c6004c5a01a66b | Python | 1,585 | 38 | """M/EEG processing pipeline.
This subpackage provides a complete pipeline for processing M/EEG data from
raw sensor recordings to parcellated source-space time courses.
Modules
-------
- :py:mod:`~osl_dynamics.meeg.maxfilter` — Wrapper for Elekta Maxfilter
(SSS/tSSS).
- :py:mod:`~osl_dynamics.meeg.amm` — Adaptive ... |
685762461fc339785f359f379deab489ee5b474c3ef9cf31963d503a8f3f8b83 | Python | 1,585 | 57 | __author__ = "Jianfeng Sun"
__version__ = "v1.0"
__copyright__ = "Copyright 2023"
__license__ = "GPL v3.0"
__email__ = "jianfeng.sunmt@gmail.com"
__maintainer__ = "Jianfeng Sun"
from typing import List, Tuple
import pandas as pd
from tmkit.base.Position import Position
from tmkit.position.scenario.Separation import ... |
c33d5d7079f1a1b50f5e4fc02a75fed288357ee8f28d72ab73025710aee59c71 | Python | 1,585 | 45 | import argparse
import tempfile
import unittest
from pathlib import Path
from unittest import mock
from alpamayo_control import ModelService
class ModelServiceTest(unittest.TestCase):
def test_preserves_virtual_environment_python_symlink(self):
with tempfile.TemporaryDirectory() as directory:
... |
e13a3f86953e080f7af640c4af48f98b6fa01143ae6d9ad0400bd661df8bf824 | Python | 1,585 | 55 | __author__ = "Johannes Köster"
__copyright__ = "Copyright 2019, Johannes Köster"
__email__ = "johannes.koester@uni-due.de"
__license__ = "MIT"
import subprocess as sp
from snakemake.shell import shell
species = snakemake.params.species.lower()
release = snakemake.params.release
build = snakemake.params.build
log = s... |
86c4f79f9578820f3f68ebd715fff1df843fd9414e566b4d4b96bae5f0a838d5 | Python | 1,586 | 49 | __author__ = "Dennis Kao"
__copyright__ = "Copyright 2020, Dennis Kao"
__email__ = "dennis.kao@sickkids.ca"
__license__ = "BSD"
from snakemake.shell import shell
from os import path
import shutil
import tempfile
shell.executable("bash")
threads = snakemake.threads
threadsprefix = "--fork {}".format(threads) if thre... |
9cd6cb7630c6099b666d5acb7cc3192d93fe5dbbf833adb8bfd8d301d4a78d68 | Python | 1,586 | 38 | # Copyright 2021 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... |
e60826e362154f779e4b10e7a562864cca49e6b7857a68a0297563e8dde13816 | Python | 1,586 | 52 | #CODE FROM KERAS
import numpy as np
import json
from keras.utils.data_utils import get_file
from keras import backend as K
CLASS_INDEX = None
CLASS_INDEX_PATH = 'https://s3.amazonaws.com/deep-learning-models/image-models/imagenet_class_index.json'
def preprocess_input(x, dim_ordering='default'):
if dim_ordering... |
c9bc92d1176f612d40af1c2a69044f811107037ea83634ca7cc69f1815521c8d | Python | 1,587 | 48 | from typing import Any, List, Optional
from zencfg import ConfigBase
from .distributed import DistributedConfig
from .models import ModelConfig, FNO_Small2d
from .opt import OptimizationConfig, PatchingConfig
from .wandb import WandbConfig
class BurgersDatasetConfig(ConfigBase):
folder: str = "neuralop/data/data... |
1ac2b9cbf5a4d0fa6449cfdcd004b0c5a501b8152c47717e8496896811207a12 | Python | 1,590 | 48 | import pandas as pd
from matplotlib import pyplot as plt
from pathlib import Path
ROOT_DIR = Path("../../../")
pd.options.display.max_columns = 50
def precision(x):
return x['tp'] / (x['tp'] + x['fp'])
def recall(x):
return x['tp'] / (x['tp'] + x['fn'])
def main():
run = '20221116_160118'
path_d... |
2fd07e1106d3d663f370e12d6eb99b115b9dbb8aa69ba4cd4b6874337e09dbf3 | Python | 1,591 | 70 | """Train DyNeMo on time-delay embedded/PCA data.
"""
from sys import argv
if len(argv) != 3:
print("Please pass the number of modes and run id, e.g. python 1_train_dynemo.py 6 1")
exit()
n_modes = int(argv[1])
run = int(argv[2])
#%% Import packages
import pickle
from osl_dynamics.data import Data
from osl_... |
8f4c36604004ccd450e2da49dae710fecaedf9f88a75cf9ea99900299b4a46e7 | Python | 1,594 | 46 | import torch
from ..segment_csr import segment_csr
import pytest
@pytest.mark.parametrize("batch_size", [1, 4])
def test_native_segcsr_shapes(batch_size):
n_pts = 25
n_channels = 5
max_nbrhd_size = 7 # prevent degenerate cases in testing
# tensor to reduce
src = torch.randn((batch_size, n_pts, ... |
764a58768f7d2235bfe3bb54e223b370cec44bd830802ed2b73e0b53d132b2b8 | Python | 1,595 | 57 | # Author: Christian Brodbeck <christianbrodbeck@nyu.edu>
from collections import defaultdict
import numpy as np
from ._data_obj import Datalist, Dataset
from ._ndvar import neighbor_correlation
from ._info import BAD_CHANNELS
def _out(out, epochs):
if out is None:
return Datalist([[] for _ in range(len(... |
a14a8e61ae0042a9dca9c7e74cb226369bc5c07e9292f139b1e35039b99d8c43 | Python | 1,596 | 43 | """ from https://github.com/keithito/tacotron """
'''
Defines the set of symbols used in text input to the model.
The default is a set of ASCII characters that works well for English or text that has been run through Unidecode. For other data, you can modify _characters. See TRAINING_DATA.md for details. '''
from . i... |
60ef10d8e991f10fa340f6056bd42f1328e4e3d1b684b8908a5047408aabdc14 | Python | 1,597 | 42 | # Copyright 2020-2022 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agre... |
8d9af21cb16b7c468b790b2c4e54dc9c7f203b36f534387acc00807db7d949d1 | Python | 1,597 | 39 | import numpy as np
import RV.constants as c
def get_y_axis_ticks(selected_channels: list, channel_offset=c.DEFAULT_Y_AXIS_OFFSET, reorder_channels=False):
"""Generates ticks for y-axis along which to align EEG traces.
Args:
selected_channels (list): List of strings of plotted channel names.
... |
be24dbd020d75e343fa800d12b60a4d2cc1808f0838a73c1c28a03c4a37f7b06 | Python | 1,598 | 51 | import numpy as np
import nibabel as nib
from utils import largestAfterOpen
from scipy import ndimage
import sys
out_path = sys.argv[1]
suit_path = sys.argv[2]
prefix = sys.argv[3]
comp_ls = sys.argv[4]
if out_path[-1]!='/':
out_path = out_path+'/'
if suit_path[-1]!='/':
suit_path = suit_path+'/'
comp_ls = comp_ls... |
264ba729ad099770a5dd52d4875ff2574928eb49023b9133e4b093093800146d | Python | 1,602 | 24 | import os
import numpy as np
sub_list_loc = "/scratch/janine.bijsterbosch/WAPIAW_2/subj_lists/sub_list.csv" # filename of list of subject IDs
read_dir = "/scratch/janine.bijsterbosch/Ruiqi/rsfMRI" # resting state data directory
savedir = "/scratch/janine.bijsterbosch/WAPIAW_2/imaging" ... |
48ab945621a1bc443fc380dd4558d4bfca8c17e4d3382ca199eb019313df7122 | Python | 1,603 | 60 | import os
import matplotlib.pyplot as plt
import numpy as np
tasks = [
"GoTask1",
"GoDlTask1",
]
go_task_list_values = np.linspace(0, 1, 8)
def plot_graph(data_a, data_v, ax_a, ax_v, letter, legend=False):
for s in range(data_v.shape[1]):
ax_a.plot(
data_a[0, s], label=f"$u_{{mod}}... |
77039a919c308dfacd40f3c7283d23baaf5f9ce0dcc92119d69baaac5bb0d356 | Python | 1,603 | 60 | import os
import matplotlib.pyplot as plt
import numpy as np
tasks = [
"GoTask1",
"GoDlTask2",
]
go_task_list_values = np.linspace(0, 1, 8)
def plot_graph(data_a, data_v, ax_a, ax_v, letter, legend=False):
for s in range(data_v.shape[1]):
ax_a.plot(
data_a[0, s], label=f"$u_{{mod}}... |
e83a2d5f0d0e81de7f6bc2ba776b54dad7bf5f6e9c6ec0db3e0d668c50b938af | Python | 1,604 | 54 | from torch.utils.data.dataset import Dataset
class TensorDataset(Dataset):
def __init__(self, x, y, transform_x=None, transform_y=None):
assert x.size(0) == y.size(0), "Size mismatch between tensors"
self.x = x
self.y = y
self.transform_x = transform_x
self.transform_y = tr... |
5cbd61f2e45934ed93f25bf4d34752734260e690a99f5df711fca6eee37d75b7 | Python | 1,605 | 45 | '''
Set up the Lumenera camera
'''
import warnings
__all__ = ['setup_camera', 'camera_parameters']
camera_parameters = {
'name': 'INFINITY3-6UR',
'total_width': 2752, # 490 * 390 um
'total_height': 2192,
'ROI_width': int(130 * 5.63), # 130 um
'ROI_height': int(130 * 5.63),
'exposure': 1.19,
... |
10d93db965d608af447b2824a8ba89a97abf9ee4394a4a368adbea6c984acdc4 | Python | 1,606 | 55 | _base_ = '../fcos/fcos_r50_caffe_fpn_gn-head_4x4_1x_coco.py'
# model settings
model = dict(
type='FCOS',
pretrained='torchvision://resnet101',
backbone=dict(
type='ResNet_MD',
depth=101,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
norm_cfg=dict(ty... |
50e79c9ddd0e0725b9dfdfca8909474bad04223aea7866800ef893100d7df6d1 | Python | 1,606 | 49 | #%%
import os
import sys
try:
os.chdir('/Volumes/GoogleDrive/My Drive/python_code/connectome_tools/')
print(os.getcwd())
except:
pass
# %%
import sys
sys.path.append('/Volumes/GoogleDrive/My Drive/python_code/maggot_models/')
sys.path.append('/Volumes/GoogleDrive/My Drive/python_code/connectome_tools/')
fr... |
9fcee1b07c40d27597addfb855981a17f5b52285adcd6e975532094a8e5258da | Python | 1,607 | 36 | ####################################################################################################
# Copyright (c) 2021, EPFL / Blue Brain Project
# Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch>
#
# This file is part of VessMorphoVis <https://github.com/BlueBrain/VessMorphoVis>
#
# This program is free softwar... |
23be2fb554e222ce473f613f943b67d4e5646452d92b0934d0329acb40cfef4c | Python | 1,608 | 52 | from torch.utils.data import Dataset, DataLoader
# Data loader that loads inputs and associated labels:
class DataLoaderLabels(Dataset):
def __init__(self, data, labels):
self.data = data
self.labels = labels
def __getitem__(self, index):
sample = self.data[index]
label = s... |
dc304b2d243c94bbf2eb921578a93b83c569fe64eea1c7dd622dfe20e3977e29 | Python | 1,608 | 44 | '''
Compares the quality of different models for hyperpolarized fits.
(Ciliated cells, 4 mM KCl)
'''
import pandas as pd
from scipy.stats import wilcoxon
from file_management.configuration import *
from os.path import join
table_folder = join(join(config['root'],'Ciliated 4 mM KCl'), 'tables')
models = ['hyperpolariz... |
dd2ca56eea832040de808537eb248c8602e97d60abc6a0072939c2690a97c064 | Python | 1,608 | 28 | # Copyright (c) Open-MMLab. All rights reserved.
from .alexnet import AlexNet
from .bricks import (ACTIVATION_LAYERS, CONV_LAYERS, NORM_LAYERS,
PADDING_LAYERS, PLUGIN_LAYERS, UPSAMPLE_LAYERS,
ContextBlock, ConvAWS2d, ConvModule, ConvWS2d,
GeneralizedAttenti... |
31b395b1820871d39e2e70027b0a06efeaf785cd2fc47fad235e72af481fdff1 | Python | 1,609 | 61 | """
2019-10-08 Master script to run a parallel jobs; input - number of threads to run
Check nx and ny!
args: number of threads
Implicit:
nx,ny
"""
import logging
import subprocess
import sys
import numpy as np
import carpet.various.parallel_with_threads as pwt
import carpet
from sim_geometry import nx, ny
## Sc... |
42a4a0167b5ac1ae6e56ff8ec8d14f8b4f20b290959cce43a932253006da2949 | Python | 1,609 | 46 | import logging
import unittest
from oaklib import get_adapter
from oaklib.conf import CONF_DIR_PATH
from oaklib.parsers import GENCC
from oaklib.parsers.association_parser_factory import get_association_parser
from tests import INPUT_DIR
G2D_INPUT = INPUT_DIR / "example-g2d.gencc.csv"
class GenCCAssociationParserTe... |
ace46cc79c257d1f4499c2817a599f0f758a7c42b4121095682166d5798508d6 | Python | 1,609 | 44 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from torch import nn
from torch.nn import functional as F
from maskrcnn_benchmark.layers import Conv2d
from maskrcnn_benchmark.layers import ConvTranspose2d
class MaskRCNNC4Predictor(nn.Module):
def __init__(self, cfg):
super(MaskRCN... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.