sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
6700e8126cd6d2025464e5215354579aa80da5a8f1c0e76f454d4a2ecb6910f8
Python
3,279
114
import csv import os from dataclasses import dataclass from pathlib import Path from typing import ( Any, Dict, List, ) from oaklib.interfaces.basic_ontology_interface import BasicOntologyInterface @dataclass class TabularFile: name: str """logical name.""" path: Path """path to the file...
1571e193169cb736a6bba763b04d5887922931e83f255e5de0b0230b677eabf4
Python
3,280
105
#!/usr/bin/env python # 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>. """ Set or inspect the weather of a running CARLA Simulator instance. Start ...
3057c77805efc86fa7fe2b632debde057fa4df091a343ff564990a16e4f4d56d
Python
3,281
104
import datetime import numpy as np import os import torch import torch.nn as nn import torch.nn.functional as F from scipy import stats from benchnirs.load import load_dataset from benchnirs.process import process_epochs from benchnirs.learn import deep_learn DATA_PATH = '../../data/dataset_shin_2018/' # path to t...
d7184a7dc0dfaf3817c6b8a9d771ee00cc8831a73b9717ea141ed5cb8d5e3f86
Python
3,281
108
""" Runs unit tests on utils.py """ import os import json from phys2bids import utils from pkg_resources import resource_filename # Tests check_input_dir def test_check_input_dir(): test_path = '/home/mrmeeseeks/blue/' assert utils.check_input_dir(test_path) == test_path[:-1] assert utils.check_input...
d9f705dc4ea8b27b9b271bfd916486a34a3bb51122d95e12c2b9d3b9e01a6c89
Python
3,282
63
import sys sys.path.insert(0, '.') from svgkit import Svg, C, render_png W, H = 1260, 720 s = Svg(W, H) s.text(W / 2, 44, "Asynchronous vs synchronous mode", size=26, weight="bold", anchor="middle") s.text(W / 2, 72, "Who decides when the simulation advances, and how much simulated time each step covers", size=1...
0360fe3fbc6d5bc0669698b66e51358ca1cdba79d906b86813ded543eed7cf22
Python
3,283
119
import torch try: import zarr except ModuleNotFoundError as e: raise e( "trying to import zarr_dataset without optional dependency zarr. Please install and try again." ) from torch.utils.data import Dataset class ZarrDataset(Dataset): """PDE h5py dataset""" def __init__( self, ...
1c3ca861a17788c512eb274d9cbcb368a2573d4d4b52951693885cf6cc5075e3
Python
3,283
110
### apply flatfield correction to s0 image import os import numpy as np from scipy.ndimage import zoom import zarr from matplotlib import pyplot as plt import seaborn as sns import tifffile import logging logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s') def transform(images, f, d=None): ...
087fbea9a11b4170a58072f662a6b43309651d50fe174ee47fa0f4f03b17c515
Python
3,284
78
import os import requests from datetime import datetime from email.utils import parsedate_to_datetime, formatdate from ddmr.utils.constants import ANATOMIES, MODEL_TYPES, ENCODER_FILTERS, DECODER_FILTERS, IMG_SHAPE import voxelmorph as vxm from ddmr.utils.logger import LOGGER # taken from: https://lenon.dev/blog/down...
287d701ebfc536069517222dad601890b964a4bb816d82f4da9d481794e0c533
Python
3,284
71
# object for analysing hit_histograms from cascades run using TraverseDispatcher import numpy as np import pandas as pd import sys import pymaid as pymaid from pymaid_creds import url, name, password, token rm = pymaid.CatmaidInstance(url, token, name, password) import connectome_tools.process_matrix as pm import con...
3a7826dfa8835eb0896944f3491d9af8afcc001c469ce466df28842d87b2925f
Python
3,284
109
#! /usr/bin/python # -*- coding: utf8 -*- import tensorflow as tf def identity(x, name=None): """The identity activation function, Shortcut is ``linear``. Parameters ---------- x : a tensor input input(s) Returns -------- A `Tensor` with the same type as `x`. """ retur...
a3c854bca5c2c846eaaf8c8b246de7c093c13d946693094ff21a48e2a13b947f
Python
3,284
70
""" Perform bootstrap resampling of performance of each ferret during vowel discrimination in noise Input ----- Data comes from the analysis directory; i.e. some preprocessing has already been done to remove correction trials and any attenuations with small sample sizes. For the cooling of vowel discrimiantion from tw...
4ce6d275cf0911ff8369d39cae044d5996f4803b4b2a892c59182150a736b2d6
Python
3,285
83
# 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...
f2488f37eaad02d81608b1980ee9acde1592189519a12b463c768d511746680c
Python
3,285
128
import glob import xml.etree.ElementTree as ET import matplotlib.pyplot as plt import numpy as np from tqdm import tqdm def cas_iou(box, cluster): x = np.minimum(cluster[:, 0], box[0]) y = np.minimum(cluster[:, 1], box[1]) intersection = x * y area1 = box[0] * box[1] area2 = cluster[:,0] * clu...
7f203b76915d400e0a013bcbf284433903c0774f9fc4bca1a6698ae34c8c54e8
Python
3,286
88
# 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...
2061bb2799667f5e04f275dedac6505cc985769b2dee3e8f521487dadf091216
Python
3,287
150
#!/usr/bin/python import time import string import sys import os import re # Set your decoder swig path in here! sys.path.append("/home/user/decoder/src/swig"); import Decoder def runto(frame): while (frame <= 0 or t.frame() < frame): if (not t.run()): break def rec(start, end): st = o...
23e3de63f7a3dc8074de152e935bed0afb0f9fbde764d959fcb38a46c57218fa
Python
3,287
85
########################################################## ## ccAF: plotNowakowski.py ## ## ______ ______ __ __ ## ## /\ __ \ /\ ___\ /\ \/\ \ ## ## \ \ __ \ \ \___ \ \ \ \_\ \ ## ## \ \_\ \_\ \/\_____\ ...
7b9f12cc7cdfefd20b11d5de028e3206934c0fac7f6a62c66f55db3a6e35bad0
Python
3,287
83
# generate molecular features from typing import Callable, List import numpy as np from rdkit import Chem, DataStructs from rdkit.Chem import AllChem, Descriptors from rdkit.ML.Descriptors import MoleculeDescriptors MoleculeFeaturesGenerator = Callable[[str], np.ndarray] MOLECULE_FEATURES_GENERATOR_R...
e328f3762e66b5c55e43e5c9184d3571ecbdacc233438801b60ebb146c47e046
Python
3,287
99
import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt from matplotlib.colors import Normalize def plot_alignments(alignment1, alignment2, transpose=True): if transpose: alignment1 = alignment1.T alignment2 = alignment2.T fig = plt.figure(figsize=(12, 7)) plt.subplot...
62bcb26370ef6fb809459802254b405a5f7af3f84c607e045c6ed1e23f46c427
Python
3,289
73
"""Post-hoc analysis of inferred state/mode dynamics. This subpackage provides tools for analysing the output of trained models (HMM states, DyNeMo modes, etc.) and for static (time-averaged) analysis. Modules ------- - :py:mod:`~osl_dynamics.analysis.connectivity` — Functional connectivity analysis (coherence, ima...
15dd6110a9fd665961935a9c0c81788963bf8542f89afe429f20ca604227572c
Python
3,290
117
""" Using `torchtnt` to count FLOPS ================================ A demo using ``torchtnt`` to estimate the number of floating-point operations per second (FLOPS) required for a model's forward and backward pass. This tutorial demonstrates how to profile neural operator models to understand their computational re...
f9a2b6e8ee4a9af6fde4922cc9d145f0f3e01c800e1e187c0549198a55e4f03a
Python
3,291
82
"""PyTorch model utility functions.""" import torch import types def cycle(iterable): while True: for i in iterable: yield i def print_module_summary(module, inputs, max_nesting=3, skip_redundant=True): assert isinstance(module, torch.nn.Module) assert not isinstance(module, torch.jit...
fafafa844c077f79996f3c5f74cd733d9877a2c046432bf5ef2501f3e54c830b
Python
3,291
97
# basic imports import os import gc import pickle import numpy as np import PyQt5 as qt import pyqtgraph as qg # framework imports from cobel.agents.dyna_q import PMAAgent from cobel.interfaces.gridworld import InterfaceGridworld from cobel.misc.gridworld_tools import make_empty_field def recover_positions(replay: li...
40da341a9aa354709ad4931fef460cb6344ff0751f4e5e393ae15d9eb79d62d1
Python
3,293
120
import os import torch from torch import nn from torch.nn import functional as F from torch.autograd import Function from torch.utils.cpp_extension import load module_path = os.path.dirname(__file__) fused = load( "fused", sources=[ os.path.join(module_path, "fused_bias_act.cpp"), ...
93770ce4787ce8dab6f3854037a591b098b40206bd33abff4ec31b7fd3923226
Python
3,293
96
import logging import unittest from linkml_runtime.dumpers import yaml_dumper from oaklib.implementations.wikidata.wikidata_implementation import WikidataImplementation from oaklib.datamodels.search import SearchConfiguration from oaklib.datamodels.vocabulary import IS_A, PART_OF WD_PECTORAL_FIN_MORPHOGENESIS = 'wiki...
337b9fcf5b92fa3f83e3b87e38ca185e5cc294f68fddc6e893789458bc9eae40
Python
3,297
96
import numpy as np from Bio.PDB import NeighborSearch, PDBParser from utils.SGCN.common import format SEARCH_RADIUS = 6 KMIN_DISTANCE_BETWEEN_ATOMS = 0.01 WATER_RESIDUES = {'HOH', 'HHO', 'OHH', 'H2O', 'OH2', 'WAT', 'TIP', 'TIP3', 'TIP4', 'TIP3P', 'TIP4P', 'SOL'} def get_elements_radii(elements_radii_path): retu...
233e4c954224ef3a7978ed17fafb38223623db6964719fa03efeed003cd0737f
Python
3,298
88
#################################################################################################### # Copyright (c) 2019 - 2022, 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 ...
2edc898c1136c30eca59d7e9df68ece622bb50f4a671a9f84881d30c13c99f84
Python
3,298
101
# Copyright 2020 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...
ef63af2bf042873313d99a791c5234b53907613d9a181b45657eaf3c93eee65b
Python
3,298
93
import argparse import collections import numpy as np from data_loader.data_loaders import * import model.loss as module_loss import model.metric as module_metric import model.model as module_arch from parse_config import ConfigParser from trainer import Trainer from utils.util import * import torch import torch.nn a...
469c6703e8d6eda6dc1abae475b6b94ba3b1ec8cc8d23efe90ff3bb2f840cb9c
Python
3,299
101
#! /usr/bin/env python import argparse, sys from argparse import ArgumentParser import re def main(): parser = ArgumentParser(description='Convert kaldi data directory to uem dat files', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('--verbose', type=int, \ dest='verbose'...
66cb4d38b3a944ae9e9c93ac0ec8000c61295fe46992ec3782bcfe9d25a09b1d
Python
3,299
99
# 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...
a49a8195b734ecba95c9b63d035f26faa5d794a0b26eb3e9d5f3c521be29c536
Python
3,299
83
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and rel...
d7cdd6bd98f5204cd27bb9a22149699f52317eff6078c7be02d1b246a8fce6b6
Python
3,299
115
# -*- coding: utf-8 -*- """ Created on Fri May 14 23:06:21 2021 @author: Sleepymouse """ import glob import numpy as np import pandas as pd from scipy.stats import chi2 import sympy import csv import matplotlib.pyplot as plt import sys #wheel managerから排出されたファイルは.csv形式(名前は.xls)なので、.xlsに変換sにて保存しなおしてから使用すること #mac #path...
9c24871f3f201875172c99b0981b648b353555528b9da6006ca166b5515e211c
Python
3,301
79
import os import cv2 import numpy as np from io import BytesIO from os.path import join from PIL import Image from slideflow.slide import stainNorm_Macenko, \ stainNorm_Reinhard, \ stainNorm_Vahadane, \ stainNorm_Augment, \ ...
7c4ef3c882057fe7a70bbdf9f0c94bd395d7ebd2327a041e107ca9724dbcc90a
Python
3,302
115
# -*- coding: utf-8 -*- import cv2 from cv2.dnn import readNet import numpy as np import traceback def anonimize(img, alg, mode=15,path="."): net = cv2.dnn.readNet(path+"/model/deploy.prototxt", path+"/model/res10_300x300_ssd_iter_140000.caffemodel") (h, w) = img.shape[:2] blo...
74ff5b2579c1a4db22cf8eb3c447eea3d01149308770bc3eb6066954df4c1b63
Python
3,303
119
import torch from torch.autograd import grad import pytest from tensorly import tenalg tenalg.set_backend("einsum") from ..fnogno import FNOGNO # Parameterize use of torch_scatter if it is built try: from torch_scatter import segment_csr use_torch_scatter = [True, False] except: use_torch_scatter = [Fal...
af67fbf47821ad6b7dd6bedec763780d16457924f85a224646c570490d3db72e
Python
3,303
93
# 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...
ed989f0c2af3d07788b1ebab867979b34d6efa309eaad4c8884507620fb7a9ec
Python
3,303
120
import os import torch from tqdm import trange import numpy as np import matplotlib.pyplot as plt from sklearn.linear_model import LogisticRegression from sklearn.model_selection import GridSearchCV from graphxai.gnn_models.node_classification.testing import train, test from graphxai.gnn_models.node_classification.te...
d952345e521d3e4fd6d0808f96bef778c1bfdd7c8884e51ee59fa36655de0546
Python
3,304
104
import hashlib import logging import shutil import zipfile from pathlib import Path from urllib.request import urlopen from tqdm import tqdm logger = logging.getLogger(__name__) MODEL_URL = "https://ndownloader.figshare.com/files/38548058" MODEL_MD5 = "ef1e07ff46ee1b0b2cf7432d438c9560" MODEL_NAME = "master" DEFAULT_...
0ea9dd2f14630c9a9297182942e0b6051e53a1221c2cd02ff54e4eda0360fc63
Python
3,306
103
import tensorflow as tf from tensorflow.python.framework import ops from tensorflow.python.ops import gen_nn_ops # @ops.RegisterGradient("MaxPoolWithArgmax") # def _MaxPoolGradWithArgmax(op, grad, unused_argmax_grad): # """The gradients for `MaxPoolWithArgmax`. # Args: # op: The `MaxPoolWithArgmax` `Operation...
8e142f4e86aa5cfae9afd52b11884657eed8076bb9c152521eded6da1ff4fe8f
Python
3,306
112
"""CTF Rest Dataset: TDE-DyNeMo for Dynamic Network Analysis. In this script we train a Time-Delay Embedded (TDE)-DyNeMo model on source reconstructed resting-state MEG data. The examples/toolbox_paper/ctf_rest/get_data.py script can be used to download the training data. Functions listed in the config are defined i...
bc2ae6961d51aeea659c5e102c79702662846589c814613c6e29943a68bd0d1a
Python
3,308
80
import numpy as np import tensorflow as tf def min_max_norm(img: np.ndarray, out_max_val=1.): out_img = img max_val = np.amax(img) min_val = np.amin(img) if (max_val - min_val) != 0: out_img = (img - min_val) / (max_val - min_val) return out_img * out_max_val def soft_threshold(x, thresh...
a2f27962f9dd78bf449a22478403e8fc8b5f30bf334662565fe68cac371d5ab6
Python
3,309
106
import pandas as pd import pytest from brian2.units import * # noqa: F403 from cxsystem2.core.exceptions import ParameterNotFoundError from cxsystem2.core.parameter_parser import value_extractor # Sample dataframe for testing def create_test_df(): data = { "Variable": ["k", "J", "k_I", "J_I", "_weights"...
dc6ac9780d0cbc60b59c9af151f04043cf8ab6181a3f68984299e7145694e57d
Python
3,309
62
#!/usr/bin/env python ################################################# ## PTDNN - Python Toolkit for Deep Neural Network ## Author: Yajie Miao ################################################# import os import sys from utils.learn_rates import LearningRateExpDecay class BnfExpConfig(object): def __init__(self...
551903faf1f3062590c545b1c854f15aa56e6573b09031e59f2318f8de8d6ca6
Python
3,310
91
import numpy as np from pathlib import Path from configparser import ConfigParser import imageio import cupy import cupyx.scipy.ndimage def get_volume_properties(obj_folder): '''Gets volume properties. :param obj_folder: Path to the folder containing slices of the segmentation. :type obj_folder: :clas...
687a993369883a6895505ff71bb88d0389b4ba4c1b18c80a4b86d8f6051720bb
Python
3,310
95
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. """ Implements the Generalized R-CNN framework """ import torch from torch import nn from maskrcnn_benchmark.structures.image_list import to_image_list from ..backbone.backbone import build_backbone from ..rpn.rpn import build_rpn from ..rpn.ret...
3bec7804d571660ac406fc5917b619399538e5709eed566a45f58d060b4048c2
Python
3,313
96
""" Takes and cleans ensembl and refseq gtfs and gffs respectively (GRCh37), saving them as csvs. wget -qO- http://ftp.ensembl.org/pub/grch37/current/gtf/homo_sapiens/Homo_sapiens.GRCh37.87.gtf.gz | gunzip -c > Homo_sapiens.GRCh37.87.gtf wget https://ftp.ncbi.nlm.nih.gov/refseq/H_sapiens/annotation/GRCh37_latest/refse...
4f257de4a0ed28f840a67854e8bf2fe471218850e7c2288aac46bb5cde7fef6e
Python
3,314
78
import unittest import numpy as np from pathlib import Path from tqdm import tqdm from copy import copy skip_tests = False try: from src.util.tracker import CSRDCFConfig, CSRDCF except (ModuleNotFoundError, ImportError): skip_tests = True here = Path(__file__).parent @unittest.skipIf(skip_tests, reason="Cup...
6ffed980bf5e89b5a3dfb5bdfe41bf8cb4014a20c55d7b6032cb6e07a92321bb
Python
3,314
96
""" Calculate the noise ceiling in single trial response estimates. Usage: python anc.py <bids_path> <subject_ID> <betas_path> <output_path> Example: python anc.py 01 /home/user/thingsmri /home/user/thingsmri/betas_vol /home/user/thingsmri/noiseceiling """ import os import sys from os.path import join as pjoin from ...
de853a6e41893dd3431a8628983662fdf2d0cd3374d90c843766addfcb21605c
Python
3,315
92
""" This file generates a dataset to be used in testing """ import json import pickle import random import os import numpy as np import pandas as pd NUM_SAMPLES = 200 NUM_GENES = 5 if __name__ == '__main__': random.seed(42) np.random.seed(42) current_dir = os.path.dirname(os.path.abspath(__file__)) ...
50f61b1136e93a71862e1459801e130609bd0bcd134199a0639e503ebb8df46a
Python
3,317
102
""" function plot_paired_data_for_Mimi function plot_paired_data_for_Mimi INPUT: - csv file containing behavioral data with cross-referenced temperature values for each trial Notes: - Testing here was done in the white elephant, so left and right responses are coded as 8 and 2 respectively. TO DO: ...
84abfb5ec325e7cd3aed9a80231c00626788f437e8bd322c5528516677dc4b3e
Python
3,317
107
# Configuration file for the Sphinx documentation builder. # # For the full list of built-in configuration values, see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master...
9c1a688cbdb1839ae312e6568226139ea4d1e68e235814bc3c81e1e041dd2670
Python
3,319
114
""" Prediction specific utility functions. """ import math import numpy as np import torch from torch.autograd import Variable from ..utils import _is_lua_trained_model def get_reverse_complement(allele, complementary_base_dict): """ Get the reverse complement of the input allele. Parameters ------...
a9883e339933b95fd1a5d547cf15c390f5de1f2ba9797effd8493c5b77dfd6e5
Python
3,319
98
# 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...
903612c220c532d369b0571d6abff1b480cf1e127f61caf0b91e9f1dfa9a64f1
Python
3,320
101
import torch import torch.nn as nn import torch.nn.functional as F class FiniteDifferenceConvolution(nn.Module): """Finite Difference Convolution Layer This is the finite difference convolution layer introduced in [1]_. It computes a finite difference convolution on a regular grid, which co...
574c7e2f6db0755949781995868932fdfaf5e4f59a91f10eddfd05207e9992f4
Python
3,323
75
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Jul 20 11:54:10 2021 @author: paulmueller For each patient look for the afni directory Then call for every electrode whereami and assign electrodes through this """ import pandas as pd import numpy as np import os import glob from iEEG_STC import get...
93fe406fc493e40e6b1f4f4001428f999639c98b344c6ce2634d5efdd3972756
Python
3,325
86
import argparse import math import glob import numpy as np import sys import os from train_double_latent_semantic import mask2color import torch from torchvision.utils import save_image from tqdm import tqdm import matplotlib.pyplot as plt import curriculums device = torch.device('cuda' if torch.cuda.is_available() e...
9734b1d4c5f8b53a2feca38855edd93aa08df4f50b6bb4e7ecca85a69e3375f4
Python
3,325
88
from typing import List, Optional from oaklib import BasicOntologyInterface from oaklib.datamodels.obograph import LogicalDefinitionAxiom from oaklib.datamodels.vocabulary import IS_A from oaklib.interfaces import OboGraphInterface from oaklib.types import CURIE, PRED_CURIE def logical_definition_matches( ldef: ...
f44791fa7dc266d2cbc361088a8395c2ba645d17a2001838509ff5293d636ab5
Python
3,325
50
import sys sys.path.insert(0, '.') from svgkit import Svg, C, render_png # Four consecutive frames: every packet is written every frame; event packets carry 0 records unless something happened. PK = [("FrameStart", "g"), ("VisualTime", "g"), ("EventAdd", "e"), ("EventDel", "e"), ("EventParent", "e"), ("Collision"...
12e53564d81fc2d0572e7915f1e9b3e8c894b47a087bc27dddc16aac46c7d8fc
Python
3,327
96
"""Module for computing basic quantities from a spectral graph model: the forward model Makes the calculation for a single frequency only. """ import numpy as np def network_transfer_local_alpha(brain, parameters, w): """Network Transfer Function for spectral graph model. Args: brain (Brain): specifi...
3986b9b93d87a2698470aeb5289412ad1444e61c9a35988697199d652f5ca6ff
Python
3,328
98
import unittest import numpy as np from numpy import testing as npt from grr import Spiketrain as spk class TestPSTH: def test_even_kernel_odd_train(self): """Even length kernel, odd length spktrain.""" spktrain = [0, 0, 0, 1, 0, 0, 2, 0, 1] dt = 1000.0 # 1000 ms = 1 s kernel_wi...
51c4310f670758b038ba4aaa6c285f7e35092b1cd3897b7bc0c81aed2ce30944
Python
3,329
110
# From https://github.com/felixpatzelt/colorednoise # MIT license """Generate colored noise.""" from numpy import sqrt, newaxis from numpy.fft import irfft, rfftfreq from numpy.random import normal from numpy import sum as npsum def powerlaw_psd_gaussian(exponent, size, fmin=0): """Gaussian (1/f)**beta noise. ...
94c5cce2fab5ba2f89895879044b52cef87a9312bdc26df06dd258754e184ad6
Python
3,329
89
# Author: Christian Brodbeck <christianbrodbeck@nyu.edu> """ Generate :class:`NDVar` (with artificial data) ============================================== .. currentmodule:: eelbrain Shows how to initialize an :class:`NDVar` with the structure of EEG data from (randomly generate) data arrays. The data is intended for...
c8272c71f069697ceb410366353ab513f8c5b9e9d5c70d7b1619bd8704e39d3c
Python
3,330
98
from posixpath import realpath import sys, os from pathlib import Path import re def read_idmap(idmap_file): sample_map = {} with open(idmap_file) as f: for i in f: sample, id = i.strip().split("\t") sample_map[id] = sample return sample_map if len(sys.argv) <= 1: pri...
95bc71a917c0c4217ef1209796c09f780765aa36e9c950e42ad2a8add5a6bded
Python
3,332
84
import os import numpy as np import pandas as pd import matplotlib import matplotlib.pyplot as plt import matplotlib.colors as colors import seaborn as sns from siVAE.util import remove_spines from siVAE.util import reduce_dimensions def plot_scalars(siVAE_output, logdir): """ """ result_mode...
9a1e94a927c2cc9b5d4c5b75fdac7f031cacaf62ea8a0c89f713964d6374bbe6
Python
3,332
96
# coding=utf-8 """ Copyright (c) 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 o...
d685fbc803a3d11e0d1b0584fcb1f9604744a2ab54cfcdb04ff3b86345899a62
Python
3,333
89
import numpy as np def initialize_sigma2(X, Y): (N, D) = X.shape (M, _) = Y.shape XX = np.reshape(X, (1, N, D)) YY = np.reshape(Y, (M, 1, D)) XX = np.tile(XX, (M, 1, 1)) YY = np.tile(YY, (1, N, 1)) diff = XX - YY err = np.multiply(diff, diff) return np.sum(err) / (D * M * N) class...
e688da77785e2d04ab02fc90f691b04eea31854e95c90d5417406e72e2c370ea
Python
3,334
84
# -*- coding: utf-8 -*- """Preview Code for 'Inf-Net: Automatic COVID-19 Lung Infection Segmentation from CT Scans' submit to Transactions on Medical Imaging, 2020. First Version: Created on 2020-05-13 (@author: Ge-Peng Ji) """ import os import numpy as np import torch.optim as optim from Code.utils.dataloader_MulCl...
3bb5947bbc8bebbf67a691a29954e161f72c3724baf63d08ffaad0c4c856990e
Python
3,335
101
import os import torch import torch.nn as nn import torch.nn.functional as F import torchvision from torchvision import transforms from torchvision.utils import save_image # Device configuration device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') # Create a directory if not exists sample_dir = 'sam...
a61d70a93a80b424af148628084b922a1c0e691605eb418574c687e08c2856cd
Python
3,335
77
# 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...
f20edef24c87234efbbfca09c92b0f338a03c071701517ec5d8ac1d1a5b7765b
Python
3,337
107
#!/usr/bin/env python # plotPSD0 ver 0.0 - a command line utility to plot a wildcarded argument # list of files containing time series data, and plot the # Power Spectral Density (PSD) of them. # This version overplots the data from multiple files. import sys, os import numpy as np import matplotlib.pyplot a...
0b5282b5feaa06ce7167398287d3dd4f6dad490175a0bd10c4490d23b8e304ba
Python
3,338
98
""" File: create_dataset_matrix.py Created: 2020/10/08 Last Changed: 2021/07/28 Author: M.Vochteloo Copyright (C) 2020 M.Vochteloo 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, e...
20e68b35025ef75c0b868d90084fc2df652b95007413cf04d99ecd7fee6ece80
Python
3,338
126
import numpy as np from scipy import stats from scipy import optimize import statsmodels.api as sm def fit_linear_model(X, y, sort=True): if sort: # assume a single regressor for now order = np.argsort(X) X = X.iloc[order] y = y.iloc[order] X = sm.add_constant(X) return sm...
6504253acbf2c90e88c61227e56d453c5c25dec51ece0f3958dd0092782a0252
Python
3,339
105
import random import torch import numpy as np import matplotlib.pyplot as plt from sklearn.metrics import f1_score from torch_geometric.data import Data from torch_geometric.utils.random import erdos_renyi_graph from graphxai.gnn_models.node_classification import BA_Houses, GCN, train, test from graphxai.datasets.feat...
70f8490e79b4b5fe94ea22685eb753fcbc7e5b5e3af7ffc835824c91507d5f92
Python
3,339
94
import sys sys.path.insert(0,'C:/Users/admin/projects/sofgan') import argparse from modules.model_seg_input import Generator from modules.BiSeNet import BiSeNet from utils import * device = 'cuda' def make_noise(batch, styles_dim, style_repeat, latent_dim, n_noise, device): noises = torch.randn(n_noise, batc...
7bc598de5d98169b45064b2b49778d7955538f9fa1deef497d84115811d89505
Python
3,340
95
""" Title ----- Dendritic I/O curve Description ----------- Dendritic integration can be quantified by comparing the observed depolarization resulting from the quasi-simultaneous activation of the same synaptic inputs, and the arithmetic sum of individual EPSPs (expected membrane depolarization). The dendritic input-o...
d136692a2b5bfcda494f5988efae53c2f3914d3b91df5e56e15d4b85e3c5a589
Python
3,340
53
# 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...
0f16b3cf136ff547593a4e3d0f3823d9491b22e92cb9ac4a93edaa1ce8b727e1
Python
3,341
101
# Header variables and parameters. import warnings with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=FutureWarning) import os import numpy as np import numpy.matlib as matlib from IPython.core.debugger import set_trace import importlib import sys from default_config.masif_opts import masi...
b2c9b930257a059422964332c1ab5ed83ad2866a8b8f602c9e28c5c44a09efa6
Python
3,341
103
#!/usr/bin/env python3 """Quick DVS sensor smoke test against a running CARLA UE5 server.""" import argparse import time import numpy as np import carla def main(): ap = argparse.ArgumentParser() ap.add_argument("--host", default="127.0.0.1") ap.add_argument("-p", "--port", type=int, default=2000) ap...
c76392a1bfae4df7dc58bc78adbc63ebb2975b4e8db0522b851bf31a411dcff6
Python
3,342
101
#%% from pymaid_creds import url, name, password, token import pymaid import matplotlib.pyplot as plt import seaborn as sns import numpy as np import pandas as pd import navis # allows text to be editable in Illustrator plt.rcParams['pdf.fonttype'] = 42 plt.rcParams['ps.fonttype'] = 42 # font settings plt.rcParams[...
ca6a4a8c8666559c99264d2c29339b788af3a11b6aff06096109153cf3492715
Python
3,342
104
import torch import numpy as np def lanczos_kernel(dx, a=3, N=None, dtype=None, device=None): ''' Generates 1D Lanczos kernels for translation and interpolation. Args: dx : float, tensor (batch_size, 1), the translation in pixels to shift an image. a : int, number of lobes in the kernel su...
68c3a02f56046d62d3bbf16b88a15a7abfeb50efb6cccd0a4cb388b9d5a7def5
Python
3,346
153
#!/usr/bin/python # # A version of recognition script to be used with lna_rec.py # import time import string import sys import os import re # Set your decoder swig path in here! sys.path.append("/home/user/decoder/src/swig"); import Decoder def runto(frame): while (frame <= 0 or t.frame() < frame): if ...
3a1557e190f9e27ce64204ed764428647b5d8e803c852ac40db60053dff06653
Python
3,347
101
""" ================================ Delineating cerebellar peduncles ================================ The cerebellar peduncles are white matter tracts that connect the cerebellum to the brainstem and cortex. In this example, we show how to delineate the cerebellar peduncles using a subject from the Healthy Brain Netw...
9a07c0dcc734f7a07005e8a84ffd858d20f83820103416320b891965c87ca7cf
Python
3,347
164
__author__ = "Jianfeng Sun" __version__ = "v1.0" __copyright__ = "Copyright 2023" __license__ = "GPL v3.0" __email__ = "jianfeng.sunmt@gmail.com" __maintainer__ = "Jianfeng Sun" class ComputLib: def interv2single(self, inf_arr, sup_arr): """ Methods ------- 1 2 ...
0954df6550e79db41c1062dbfdaed0f2c027292b58743b916f11496f7868f594
Python
3,348
78
import numpy as np import pandas as pd from scripting.spectrum.io import dialogs, paths from scripting.spectrum import metadata from scripting.utils import replace def get_paths(t1="Scores", t2="Artifact Probs", matched_chars=11): """Get matched paths for scores and artifact probabilities text files along wit...
84931a9b9485f9dc886d04faf278dcd23c3f11777455c9a7333d3b7bf8c82bbb
Python
3,348
98
from dataclasses import dataclass from typing import List from deprecated.classic import deprecated from oaklib.datamodels.search_datamodel import ( SearchBaseConfiguration, SearchProperty, SearchTermSyntax, ) from oaklib.datamodels.vocabulary import ( IDENTIFIER_PREDICATE, LABEL_PREDICATE, SY...
a54c91ac732802e597fd7df0d291d297383bca5162ca6289edabaa5224b6f345
Python
3,348
98
from timm.scheduler.cosine_lr import CosineLRScheduler from timm.scheduler.multistep_lr import MultiStepLRScheduler from timm.scheduler.step_lr import StepLRScheduler from timm.scheduler.tanh_lr import TanhLRScheduler def build_scheduler(optimizer, cfg): num_epochs = cfg['TRAIN']['MAX_EPOCH'] scheduler_cfg =...
1913a898487166c7b64e51089ff4603dac4a5114f2d29c3b1f2f269d538cd97e
Python
3,349
134
''' Statistics of hyperpolarized fits ''' import pandas as pd from pylab import * from matplotlib import gridspec import seaborn from file_management import * from os.path import join width, height = 8, 3 table = pd.read_csv(join(config['root'], 'Ciliated 4 mM KCl', 'tables', 'selection_hyperpolarized.csv')) # Selec...
833017267c04bd3d069f00de358fe6a2a40628e1e2acf132d4af6243589ed522
Python
3,349
113
import math import glob import argparse parser = argparse.ArgumentParser(description='Create slurm jobs to make genomicDB from multiple gVCF files') parser.add_argument('list_of_vcfs', help='.txt file with list of path of VCFs to merge (only for chr15, this will be replaced for other chr numbers)') parser.add_argum...
b1363be92783c71baa5932ec77db3f712292693c5b5837dffae78c917cd21400
Python
3,350
112
# Copyright (c) Open-MMLab. All rights reserved. from __future__ import division import numpy as np from mmcv.image import rgb2bgr from mmcv.video import flowread from .image import imshow def flowshow(flow, win_name='', wait_time=0): """Show optical flow. Args: flow (ndarray or str): The optical f...
199a8ff559c99a194095698966883b6a331ae2088e9be3d6c6013caa3b516679
Python
3,351
64
"""API + scheduler: a scene-package control is rendered server-side before dispatch.""" from carla_cosmos.client import sha256_file, zip_dir from carla_cosmos.synthetic import av7_clip, make_clip from conftest import make_server, submission def _upload_scene(ctx, clip, tmp_path): z = zip_dir(clip.scene_dir, tmp...
9f260eba51d05814459751524b5bf3d60a1bf9b3c80aadd94139ac78c501edcc
Python
3,351
79
"""MobileNetV1 for Semantic Segmentation""" import torch import torch.nn as nn import torch.nn.functional as F from models.baselines.base import BaseModel _all__ = ['MobileNetV3'] class MobileNetV3(BaseModel): def __init__(self, classes=2, aux=False, backbone='mobilenetv3_small', pretrained_base=False): ...
f10c7b7993727db0dbefccd2778cfbd07adb3c0f060b0c0d2f02dce0f85edb93
Python
3,352
79
"""MobileNetV1 for Semantic Segmentation""" import torch import torch.nn as nn import torch.nn.functional as F from models.baselines.base import BaseModel __all__ = ['MobileNetV3'] class MobileNetV3(BaseModel): def __init__(self, classes=2, aux=False, backbone='mobilenetv3_small', pretrained_base=False): ...
db56f3f3ef2d8815b53f3da0b0c8dbd834cadb1b35b937369f72c5886947fe7c
Python
3,353
62
import os # Heuristics created by Vincent for Abbas dataset sample6. # 27th Nov. 2019 # updated 23th Jan. 2020 def create_key(template, outtype=('nii.gz',), annotation_classes=None): if template is None or not template: raise ValueError('Template must be a valid format string') return template, outtype,...
6f12f5f433c81b8373cb858cc5047f02f24395049709272b68a8dc28255cd0e8
Python
3,354
93
''' Calculates the mean angle near the anterior and posterior ends. Here the mean angle is calculated on the half-plane beyond the anterior/posterior ends. ''' import os import numpy as np from file_management.batch_processing import * from file_management.configuration import * import sys from scipy.stats import circm...
fe3e8bc94332b0ccad92ee953de865d9bdb4ec61a49718a14218b3a1858c227f
Python
3,354
93
"""Quick tests for SFNO (Spherical FNO). SFNO is FNO with SphericalConv; 2D only.""" import pytest import torch try: from neuralop.models import SFNO except ImportError: SFNO = None @pytest.mark.skipif(SFNO is None, reason="SFNO not available (torch_harmonics required)") @pytest.mark.parametrize("n_modes", [(...
30a6adeb693d3ca9d571b7390814cfe6409d8e5822372f92d824b8c0f8d6568e
Python
3,355
107
""" © 2022, ETH Zurich """ import itertools import os import pickle import numpy as np import pandas as pd from rescoss_logp_ml.utils import SEED, get_output_dir def get_model(model_name, **h_params): """Construct specified model with hyperparameters. Imports done inside function for compatibility with differ...
4898796922061576914751e1b8279f83f10a0846ed5fab7a44f513790e2f1d91
Python
3,355
85
# 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...
70e1e3d4ab7b9c752cfebe2ca12f94fa070b5f8d269e69bc72baa1f9ca34b705
Python
3,355
100
import torch import glob import unicodedata import string import random import torch all_letters = string.ascii_letters + " .,;'-" n_letters = len(all_letters) def findFiles(path): return glob.glob(path) # Turn a Unicode string to plain ASCII, thanks to http://stackoverflow.com/a/518232/2809427 def unicodeToAscii(s)...
dfa241dd57aa0f96d094d341814d72f9239ad1fb6f2304f505745f5dbd2523b0
Python
3,356
93
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Script to launch a grid-search over hyperparamters, using the run_train.py script. Created on Wed Oct 31 16:38:54 2018 @author: nicolas """ import os, sys, time import numpy as np # Add parent folder to path in order to access `axoid` sys.path.insert(0, os.path.absp...
1af1024dbeaa220f31524f9748e9b21143b9024b4f5543c3ed061f932aa5da0e
Python
3,358
107
from dataclasses import dataclass from typing import List import oaklib.datamodels.obograph as og from oaklib import BasicOntologyInterface from oaklib.datamodels.vocabulary import ( IN_TAXON, IS_A, NEVER_IN_TAXON, ONLY_IN_TAXON, PART_OF, ) from oaklib.interfaces.obograph_interface import OboGraphI...