sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
e967dd4b7c9874c3a9d1d14e75fba33d26b2c76c24077e60f7f0da148b3321a8
Python
2,181
90
# %% [markdown] # ## import pandas as pd import numpy as np connector_loc = "maggot_models/data/processed/2020-06-10/connectors.csv" connectors = pd.read_csv(connector_loc, index_col=0) sizes = connectors.groupby( ["connector_id", "presynaptic_type", "postsynaptic_type"] ).size() sizes.name = "count" sizes = siz...
b178672759bbbbc7b515173d49ab299eb39d13a0771ebf07b7b19fd169b67e3d
Python
2,182
57
# 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...
7d5daff8641ea98a9f43147faaee935a8415c4f44f65f1f068f61e0e0e8d1087
Python
2,183
71
########################################################################################## ## Create gene x cell type matrix containing % of cells in each cell type expressing gene ## using human cortex gene expression matrix from Velmeshev 2019 (scRNA-seq) ## ## Author: Yu-Han Hsu #####################################...
aca97044998f19d7637bc22c5b28b45e566f393974e0b6cf16900b9e4a947ac5
Python
2,185
79
""" Implements basic graph algorithms such as BFS. Author: Mengye Ren (mren@cs.toronto.edu) Usage: """ import numpy as np def bfs(adj, src, dst, cache=None): """BFS search from source to destination. Check whether a path exists, does not return the actual path. Work on directed acyclic graphs where we assume...
cb63238f91bac7592c1ca4aefe8a52a2da8519102ddbd6014858fb141269fadc
Python
2,186
57
# 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...
786caa3ee358c2e89dd23a0c1d7578d323e6dc0cbc022cf7d8d5104d032cb26b
Python
2,188
81
# An example config file to be sent to wandb import sys sys.path.append("E:\BRATS_Research\BraTS-2021\src\model") from wandb_creds import get_wandb_credentials from loss import SoftDiceLossSquared from ..model.spp_3d import Pyramid_Pooling_3D import wandb import torch wandb.login(key=get_wandb_credentials(person...
b425e48b21f6f03be6f27d7615cd0b648bfac3420a39230dd584e758d0f53de3
Python
2,188
70
# Pablo Gainza Cirauqui 2016 # This pymol function loads dot files into pymol. from pymol import cmd, stored from pymol.cgo import * import os.path import numpy as np colorDict = { "sky": [COLOR, 0.0, 0.76, 1.0], "sea": [COLOR, 0.0, 0.90, 0.5], "yellowtint": [COLOR, 0.88, 0.97, 0.02], "hotpink": [COLOR...
3e9e661ce1851ff5cf5a3d05af610ab2a7da8a0002e877e7f06fa8638a8ce07c
Python
2,189
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 agreed to...
47f8cc5e2e7290be28372a44391c043b26a24187c24a0a8cff85a1d098ea534c
Python
2,189
58
# Merge STAR gene count files (counts per sample) to matrix with rows genes, columns samples # NOTE: Needs Python version 3.5+ import glob import argparse parser = argparse.ArgumentParser(description='Merge multiple STAR count files into a matrix.') parser.add_argument('star_base_path', help='base path from where to s...
5782766bd72229ff93eb084b3c15deb5bd5445f5080ce9c4f427510588144021
Python
2,190
43
import os import shutil from tqdm import tqdm import pandas as pd dataset_folder = '/data/interesting_side_projects/SSAML/datasets' predict_folder = '/data/interesting_side_projects/SSAML/models_predictions' # find the common file names that exist both in dataset and prediction dataset_files = [x.replace('.csv','') ...
5cd1b18d3e575d7a5f9f671d5904f38c0dcfdfbbaae2ed1893c821faff6345ab
Python
2,192
67
import os import pickle import torch from torch.utils.data import Dataset from torchvision.transforms import Compose, RandomHorizontalFlip, RandomVerticalFlip from utils.helpers import Fix_RandomRotation class vessel_dataset(Dataset): def __init__(self, path, mode, is_val=False, split=None): self.mode = ...
bb371dd2011c3c795089bffc59277f528c096cd50d2c5df072b87628ccc1ea65
Python
2,192
61
#!/usr/bin/env python3 """ File: analyse_interactions.py Created: 2020/03/13 Last Changed: 2020/03/19 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 Fre...
d3f5a03092f8d6422006f9f1fd0f1fcfdb15ca649c2b43c13a210a8110a1abb1
Python
2,193
56
from spike2calcium import * import os, sys import warnings warnings.filterwarnings('ignore') from glob import glob # get cell list information flist = sorted(glob('GCaMP8_exported_ROIs_s2f_full/dff/*.npz')) cell_info=["_".join(os.path.basename(f).split('_')[:6]) for f in flist] cell_info_uq = np.unique(cell_info) # s...
136ab5c012a5d8373133cc577433a08bd80e55efa39bab33537f79b8189cdc41
Python
2,194
73
# import sys import fnmatch def heur(physinfo, name, task='', acq='', direct='', rec='', run=''): # ############################## # # ## Modify here! ## # # ## ## # # ## Possible variables are: ## # # ## -task (required) ## # # ## -run ...
13dac2301cfd5086cc83519f617a85f1e71c5da89f45957bd39c28c659168239
Python
2,194
67
import argparse import torch import torch.nn as nn from mmcv.runner import save_checkpoint from mmdet.apis import init_detector def fuse_conv_bn(conv, bn): """During inference, the functionary of batch norm layers is turned off but only the mean and var alone channels are used, which exposes the chance to ...
dd361289f71824fc40a0bfc7d0153c676b20357805e433b4ff5854db5955387b
Python
2,194
76
import h5py import torch from torch.utils.data import Dataset class H5pyDataset(Dataset): """PDE h5py dataset""" def __init__( self, data_path, resolution=128, transform_x=None, transform_y=None, n_samples=None, ): resolution_to_step = {128: 8, 256:...
2679f1dfef559df24e4da2bd0aba721ddf9a19e477003a75a0cb62bb8ae8a157
Python
2,195
71
import tkinter as tk import tkinter.filedialog as tkdialogs import os from pathlib import Path def root_deco(dialog): """Decorates a dialog with a toplevel that is destroyed when the dialog is closed.""" def decorated(*args, **kwargs): #create root and withdraw from screen root = tk.Tk() ...
5863cd335bb21cdcf2e211614ea2d20c5467c7c12bc1e7410c2c2fa0eeab7123
Python
2,195
60
import random import torch import matplotlib.pyplot as plt from tqdm import trange from graphxai.explainers import PGMExplainer from graphxai.gnn_models.node_classification.testing import GCN_3layer_basic, GIN_3layer_basic, test, train from graphxai.datasets.shape_graph import ShapeGGen # Load dataset: # Smaller gra...
fdae66f9f44abdb3f5a1b58e5329b2056b58f186964e7edb6bd61aa10d00a4c9
Python
2,195
56
import argparse from bunch import Bunch from loguru import logger from ruamel.yaml import safe_load from torch.utils.data import DataLoader import models from dataset import vessel_dataset from trainer import Trainer from utils import losses from utils.helpers import get_instance, seed_torch def main(CFG, data_path, ...
597c3c1bc8079084ad6503c82739139a912c318eae94d1792f4320262a2f7aa1
Python
2,196
66
#################################################################################################### # Copyright (c) 2019, 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...
f2875ef9ca21169dde163fb1ee6323ed09f194351be882e58ce827d79a6297d0
Python
2,196
82
import pickle import numpy as np import re from nltk.corpus import stopwords from charpragcap.utils.image_and_text_utils import devectorize_caption,split_dataset,get_rep_from_id import copy def cap_to_words(cap): return [word for word in re.sub('[^a-z ]',"",devectorize_caption(cap)).split() if word not in stopwords.w...
0e49b3081811114356e2e6a075ea7bbf570bb0162e10f5c7c2f41db7a60952e7
Python
2,198
79
__author__ = "Jianfeng Sun" __version__ = "v1.0" __copyright__ = "Copyright 2023" __license__ = "GPL v3.0" __email__ = "jianfeng.sunmt@gmail.com" __maintainer__ = "Jianfeng Sun" from typing import Optional from tmkit.seqnetrr.Controller import Controller def extract( method: str, fasta_fpn: str, net_fpn...
7b06bef6d6b201693acd1b7ba9da2286aadf27e052569ceec0b7ccef8b3ee241
Python
2,198
42
# Author: Christian Brodbeck <christianbrodbeck@nyu.edu> from eelbrain._experiment.definitions import find_dependent_epochs, find_epoch_vars, find_epochs_vars from eelbrain._experiment.test_def import find_test_vars from eelbrain._experiment.variable_def import Variables def test_find_epoch_vars(): assert find_ep...
4bc7bcf7839f2f84e4bb8651706c9c2e725a5af86c2ecb2503b16a14a5ab87b5
Python
2,199
61
# 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...
24880c0e6d126226d5183e05a80c741b669b36aee0de9aa19feaefd6ca8e2a73
Python
2,202
85
from os.path import basename from pathlib import Path import numpy as np from sacred import Experiment from sacred.observers import FileStorageObserver, SlackObserver from graspy.datasets import load_drosophila_left, load_drosophila_right from graspy.utils import binarize, symmetrize from src.models import select_sbm...
2634d4f52b0c4b72d6e1e7ab91c1e3d6d89b076d8b45e96c2364022663aa39be
Python
2,202
67
from helper.NumpyEncoder import NumpyEncoder from datetime import datetime import matplotlib.pyplot as plt import json import math import pathlib def get_file_locations(architecture, num_examples, solver): arch_str = '-'.join([str(z) for z in architecture]) plot_dir = "results/plots/%s/%s/%s" % (arch_str, num_exam...
575808d7e7196f7f6742067c1bffedbaf7219aebac3b096fdbb1068c58a3f88b
Python
2,202
62
import numpy as np import skimage.morphology as skmorph import scipy.ndimage def compute_statistics(result, skeletonized_result): '''Summarize results. Inputs must be labeled arrays with classes 0,1,2''' N_neg = (result == 0).sum() N_mask = (result == 2).sum() result ...
b66cf206d10f07647f8d2654e232f60396a31c0ebca5d94f7a5b48e3fcfe078a
Python
2,202
76
from keras.callbacks import TensorBoard, ModelCheckpoint, CSVLogger from models import ResearchModels from data import DataSet import tensorflow as tf import os import argparse import numpy as np from sklearn.metrics import roc_curve, auc import matplotlib.pyplot as plt def validate(data_type, model, seq_length=24, sa...
706ba3208cfc4b4ff65ee15e300c73628d19bc1f8c1e4f273c7197274e46d74e
Python
2,203
66
# Copyright (c) Open-MMLab. All rights reserved. import numpy as np import torch.nn as nn def constant_init(module, val, bias=0): if hasattr(module, 'weight') and module.weight is not None: nn.init.constant_(module.weight, val) if hasattr(module, 'bias') and module.bias is not None: nn.init.co...
8c8eb1b986d003b51348f38ec32039f87550ddb23a1d85245a3d99fc574e3a29
Python
2,205
64
import sys import numpy as np import torch from torch_geometric.datasets import TUDataset from graphxai.explainers import GuidedBP from graphxai.explainers.utils.visualizations import visualize_mol_explanation from graphxai.gnn_models.graph_classification import GIN, load_data, train, test import matplotlib.pyplot as...
aee4fce42e59145771dd092d391c98f76a48c5885bca2c3c8224d1d7c243ac65
Python
2,205
85
from os.path import basename from pathlib import Path import numpy as np from sacred import Experiment from sacred.observers import FileStorageObserver, SlackObserver from graspy.datasets import load_drosophila_left, load_drosophila_right from graspy.utils import binarize, symmetrize from src.models import select_sbm...
7512eefc3f989725633a83efc25ac05327f54ccf6a0e7944046736db64852901
Python
2,206
76
import torch import torch.nn as nn import numpy as np class fBMGenerator(nn.Module): def __init__(self, dim, **kwargs): self.dim = dim super(fBMGenerator, self).__init__(**kwargs) def f_(self, DT, alpha): return 0.5 * ( torch.pow(torch.abs(DT + 1), alpha) + tor...
d6134e5707eeed014f97749c7037a2dc7e78b0d2f8c7f2f0f521d7a383a5a857
Python
2,206
83
"""Graph decoders.""" import manifolds import torch.nn as nn import torch.nn.functional as F from layers.att_layers import GraphAttentionLayer from layers.layers import GraphConvolution, Linear class Decoder(nn.Module): """ Decoder abstract class for node classification tasks. """ def __init__(self,...
65ede7aa706eec7d85ce4242c29b7b10ab397dc767b1afea38e5271913058513
Python
2,207
63
# loop through all subdirs to find all fastq files import os.path import re import argparse parser = argparse.ArgumentParser(description='Make Molgenis Compute samplesheet for MayoCBE.') parser.add_argument('samplesheet', help='MayoCBE samplesheet from synapse') parser.add_argument('fastq_dir', help='path to fastq f...
040432d81f203efab206bc0a963076a630c3e3cefbb631c9a494f41cb8b1f845
Python
2,208
88
import pickle from copy import deepcopy import numpy as np import grr.GIF_network as gfn from lib import generate_models_argparser, load_generate_models_opts # Parse commandline arguments args = generate_models_argparser.parse_args() opts = load_generate_models_opts( args.opts, { 'dt': None, ...
65b51c25d1e6cff8b80034846562651f307d8de8232eb0d4992aa94ba1e66769
Python
2,208
55
from ..builder import DETECTORS from .two_stage import TwoStageDetector @DETECTORS.register_module() class FastRCNN(TwoStageDetector): """Implementation of `Fast R-CNN <https://arxiv.org/abs/1504.08083>`_""" def __init__(self, backbone, roi_head, train_cfg, ...
8c761d3a9c591dcebc5799bb803ed3239e754a8d7c2d421131dcb86fa3fd6c7a
Python
2,210
74
from dataclasses import dataclass from pathlib import Path from typing import TYPE_CHECKING, Optional, Type, Union from class_resolver import HintOrType if TYPE_CHECKING: from .interfaces import OntologyInterface __all__ = [ "OntologyResource", ] @dataclass class OntologyResource: """ A representat...
00d91a58df67ee425be02da84c030824a5c575ea44a10f469b315901253c09aa
Python
2,211
78
# 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...
5927dd4831506c26851252640402831cc45b761bfb6d20437fe52686c678a2a8
Python
2,211
57
import tqdm import argparse, sys, os import random as rand import torch from graphxai.explainers import * from graphxai.datasets import load_ShapeGGen from graphxai.datasets.shape_graph import ShapeGGen from graphxai.utils.performance.load_exp import exp_exists from graphxai.gnn_models.node_classification.testing impo...
d92ac59a2453d293cb9fbbfe9527956850820ec1fabf0de9eb2afeaeb520a91b
Python
2,212
87
""" From https://github.com/wanghao14/Stain_Normalization Normalize a patch stain to the target image using the method of: E. Reinhard, M. Adhikhmin, B. Gooch, and P. Shirley, ‘Color transfer between images’, IEEE Computer Graphics and Applications, vol. 21, no. 5, pp. 34–41, Sep. 2001. """ from __future__ import div...
19ad82121804f0b97114904ed7af58abea342c59b1557aa7c1d278e13e653b90
Python
2,213
63
# Author: Christian Brodbeck <christianbrodbeck@nyu.edu> from pathlib import Path import numpy as np from numpy.testing import assert_array_equal from eelbrain import Dataset, datasets, load from eelbrain.testing import TempDir, assert_dataobj_equal, assert_dataset_equal, file_path def test_r_tsv_io(): "Test re...
057ba316e18d694c26d77ff0ae68d38199c596c0024c54271647bae818aa7de3
Python
2,214
71
import tensorflow as tf def adam(loss, lr, train_vars, beta1=0.9, beta2=0.999, epsilon=1e-8): opt = tf.compat.v1.train.AdamOptimizer( learning_rate=lr, beta1=beta1, beta2=beta2, epsilon=epsilon, name="Adam" ) grads_and_vars = opt.compute_gradients(loss, train_vars) ...
184007f780b707e0cdb7e355317a01a60114221a6cc6b4dd1889359f035bbfac
Python
2,214
71
from __future__ import absolute_import from __future__ import division from __future__ import print_function import multiprocessing import tensorflow as tf from tflib.data.memory_data import MemoryData _N_CPU = multiprocessing.cpu_count() class Mnist(MemoryData): def __init__(self, batch_si...
a6719a366a12947f53e03e7e4bf9ed3ac18a4fe2985d6b1d37f87926e7f719c8
Python
2,214
73
"""Step 1: Preprocessing.""" from pathlib import Path import mne import matplotlib matplotlib.use("Agg") from osl_dynamics.meeg import parallel, preproc # ---------------------------------------------------------------------------- input_dir = Path("BIDS") output_dir = Path("derivatives") qc_dir = Path("qc") log_dir ...
e23e15e93faafabb6356d3c1bc5907185950b30a240e1edbb115c3d0831818ee
Python
2,214
61
import ipdb import random as rand import torch import argparse import numpy as np from graphxai.gnn_models.node_classification.testing import GCN_3layer_basic, GIN_3layer_basic, test, train, val from graphxai.datasets.shape_graph import ShapeGGen from graphxai.datasets import load_ShapeGGen parser = argparse.Argumen...
74ed2361d6fd45cc59181e4984d3240332e2e47dd796e60d595d90620e5f1c55
Python
2,215
61
# Merge STAR gene count files (counts per sample) to matrix with rows genes, columns samples # NOTE: Needs Python version 3.5+ import glob import argparse parser = argparse.ArgumentParser(description='Merge multiple STAR count files into a matrix.') parser.add_argument('star_base_path', help='base path from where to s...
d4e26cffe1198b5f2577b119de4cb34985b2c017125d02ce7f7d8e6457c55a8b
Python
2,215
61
import numpy as np import torch import torch.nn as nn from mmcv.cnn import constant_init, normal_init from mmdet.models.anchor_heads.ssd_head import SSDHead from mmdet.models.registry import HEADS from .operations import conv_dw_head @HEADS.register_module class SSDLightHead(SSDHead): def __init__(self, ...
4025c606cd9d8d1a3fd5122a4232d335e30f3ce679f218d6db9428671d16953b
Python
2,216
60
#################################################################################################### # Copyright (c) 2019, 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...
105ff5e23f2eb0949ea3bb40f6e6ec700bd3464ff8b76393707cd64afbb5af4d
Python
2,218
59
# 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...
2d1a0618605cc87b41b376f543ecb5beb25491861d0f00f28d6de05fb7c6c815
Python
2,218
71
""" A utility for testing config options for the zebra test. Change settings until the program identifies exactly 1 blob over the fish""" """IMPORTS""" import numpy as np import cv2 from skimage import feature import time import matplotlib.animation as am from matplotlib import pyplot import csv import configpars...
542225a61d0fe467b4ce70607c0227ccb415a1698d7e5e12c2f46031e031f98b
Python
2,219
61
# 0. Choose a blueprint for the walkers world = client.get_world() blueprintsWalkers = world.get_blueprint_library().filter("walker.pedestrian.*") walker_bp = random.choice(blueprintsWalkers) walkers_list = [] all_id = [] # 1. Take all the random locations to spawn spawn_points = [] for i in range(50): spawn_poin...
6bff488385a96425d99522462dc8fc1494f8f8d49cc27f1287895d217207d91d
Python
2,221
53
# Copyright 2021-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...
1b0716e4caa9e8a18cebebf3f6f767858ce135bc73faa4bf46001cdea0485830
Python
2,222
50
# 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...
2a825e37d92ecfbb03348a1f10e26c50ea0844d230256f714e85726dbbe9546b
Python
2,223
73
"""Computing the path length covered by each mitochondrion""" import sys import argparse from collections import defaultdict from tqdm import tqdm import numpy as np import pandas as pd sys.path.append(".") from lib import compartment, skel, u def main(mitodffilename, idfilename, mitotoskelfilename, outputfilename)...
9f6cb815f1c31bcdda54721b21aa4c94f8b7a588c76d3ab23de694613889ab0a
Python
2,223
91
""" Process an image that we can pass to our networks. """ from keras.preprocessing.image import img_to_array, load_img import numpy as np import cv2 import random import tensorflow as tf from keras_preprocessing import image def process_image(image, target_shape,): """Given an image, process it and return the arr...
1791c8d7487e5b05b4d99e45904fed16eab217b51242288c7928a3fb06ce8601
Python
2,224
58
import numpy as np from utils.postprocessing import PostProcessing from utils import embedding_matrix_2_kNN from utils.Config import Config from utils.ArticlesProvider import ArticlesProvider class SelectLabelsPostprocessor(PostProcessing): """ Select smartly the articles to label to optimize the result "...
72d88d13307e9b8cd01b83fedc10840fde150c5853f0350ee111ae1c0afc7a73
Python
2,224
85
import random import numpy as np from deap import base from deap import creator from deap import tools from deap import algorithms import argparse import pandas import os import numpy as np import matplotlib.pyplot as plt import functools from collections import Counter import math import random def main(args): ...
9f931e7da37f6a3ae3e72a4a99cad9cd88f332008e9a7c55007bf8bf191a39ce
Python
2,225
63
""" THESE FUNCTIONS WERE ADDED BY HELLE FROM: https://github.com/BenevolentAI/guacamol/blob/8247bbd5e927fbc3d328865d12cf83cb7019e2d6/guacamol/utils/data.py#L11 to solve AttributeError: module 'utils' has no attribute 'canonicalize_list' """ from typing import Optional, Iterable, List from rdkit import Chem def canon...
8e02ed9de9a1ec95365f1cb2c8acc03ffa159aed1a1f4ad16f03df4823130c3f
Python
2,226
64
# -*- coding: utf-8 -*- import sys from pathlib import Path class DirectionTree(object): """generate file tree like `tree E:/xxx/xxx` command in windows pathname: target directory filename: save directory, default = 'tree.txt' """ def __init__(self, pathname='.', filename='tree.txt'): sup...
2b58eb1dec37e965680ac7003f4ece9b346c1a9e27bf6422978c23c00a22f530
Python
2,227
92
""" Test the `InputSignal` class in input_architect.py and all its methods. """ import sys sys.path.append('../../../') sys.path.append('../') import numpy as np # nest.init(sys.argv + ['--verbosity=QUIET', '--quiet']) # turn off all NEST messages from modules import parameters from modules import input_architect ...
ff75d8d9ec2a0adc2e707a666cafdd2213f8092d62b90ff258ce496b18af9a55
Python
2,228
55
import argparse import mne import numpy as np from os import path from ..infer import EEGInfer from ..utils import inst_load, output_stages, pick_chan_names, graph_summary def main(): parser = argparse.ArgumentParser() parser.add_argument("file", type=str) parser.add_argument("--out_form", type=str, defau...
74b1a9a02603a9adcaf38266428147b6b6c79654e403495b69ceed3d80fa9332
Python
2,229
57
# 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 from maskrcnn_benchmark.modeling import registry @registry.ROI_MASK_PREDICTOR.register("...
ee36dac0984c7d83018e741b2a461b1e317473854c3cfc7c69a8e075386b480d
Python
2,229
68
# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html import os import sys from datetime import datetime, timezone # -- Path setup ---------...
7ac143adf6fa54012d3a0bbe984f3ca36104aab99028af0b6d34f6ab48cf184f
Python
2,231
60
#################################################################################################### # 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 ...
7cf93e02ccb3a39b984d43e69d0838c2e487198b7c3fe7a6d8b43763615e4ff5
Python
2,231
65
import sys import numpy as np import torch from torch_geometric.datasets import TUDataset from graphxai.explainers import GuidedBP from graphxai.explainers.utils.visualizations import visualize_mol_explanation from graphxai.gnn_models.graph_classification import GCN, load_data, train, test import matplotlib.pyplot as...
e5c3527c67c0784238dbcb38c6fd5d7f6cc94605e874fa1712dbb9b4342da854
Python
2,231
62
# 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...
3d5871e1e98b9b5cdbca2b208e208c639835bb6ab37854d6b33acdf5417676d5
Python
2,232
59
import torch import pickle import os import numpy as np import pandas as pd from rulenn.rule_nn import RuleNNModel VERBOSE = False def print_rules(df: pd.DataFrame): for row in df.iterrows(): print(" & ".join(df.columns[:-1][row[1][:-1]>0.3]) + " => " + str(row[1][-1])) def apply_rules(container:RuleNN...
0ff0736a8351f6ea890972555b52802213ecba1d0f0bc7144feee930c94e960f
Python
2,233
46
# functions/add.py import torch from torch.autograd import Function import numpy as np class AffineGridGenFunction(Function): def __init__(self, height, width,lr=1): super(AffineGridGenFunction, self).__init__() self.lr = lr self.height, self.width = height, width self.grid = np.ze...
04cc4d95a107af527d8fe0230f49bedef668c5fb7fd1322860710830e64bddc9
Python
2,234
64
from functools import reduce from mne import SourceSpaces import numpy as np from .._data_obj import _point_graph def merge_volume_source_space(sss, name='Volume'): """Merge multiple volume source spaces into one Notes ----- Only intended to work properly if ``sss`` is the output of a single :f...
2973d9383eabaec859b83dc8da3d9c9ca7e560b82eeb531c350f53d1948eac98
Python
2,236
63
''' Ohmic IK model with bell-type time constant, for fitting depolarized responses in deciliated cells. p = 2 and baseline time constant nearly 0. Time constant peaks at V_IK, with slope twice the activation slope. Maximum time constant 3 ms. ''' from file_management import * from brian2 import * from brian2modelfittin...
7ae515bdddde9d43de42ac7094bd7c4a3936af951031ade1f91d3fe4acfc0ee6
Python
2,238
86
from os.path import basename from pathlib import Path import numpy as np import pandas as pd from sacred import Experiment from sacred.observers import FileStorageObserver, SlackObserver from sklearn.model_selection import ParameterGrid from graspy.datasets import load_drosophila_left from graspy.utils import binariz...
68ba499324745ea02e843a7b7d8bc68b1648df0974765ed51d47dbbe07a40201
Python
2,242
54
# 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...
d47539217e4d9b0cba82c87fea99ca7544b9d1540d0365e183c7e20ac2c6dbc1
Python
2,242
67
import argparse import os import sys import torch from PIL import Image import torchvision.transforms as transforms from networks.drn_seg import DRNSub from utils.tools import * from utils.visualize import * def load_classifier(model_path, gpu_id): if torch.cuda.is_available() and gpu_id != -1: device = ...
9cd5d974a4508a5cfa72917e9d29d026b47c14b5f954310e2fbd356044ef84f1
Python
2,243
59
import torch from torch.utils.data import Dataset import os import numpy as np class LoadDataset_from_numpy(Dataset): # Initialize your data, download, etc. def __init__(self, np_dataset): super(LoadDataset_from_numpy, self).__init__() # load files X_train = np.load(np_dataset[0])["x"]...
b50bebd0dd439e8638d58a6cbf72ac0919ddc91441fa6129d2436d4ec6ffd8e7
Python
2,244
68
import logging from dataclasses import dataclass, field from typing import Type import rdflib from linkml_runtime.dumpers import rdflib_dumper from linkml_runtime.utils.yamlutils import YAMLRoot from rdflib import SH from rdflib.term import Node from oaklib.datamodels.obograph import RDF, PrefixDeclaration from oakli...
e39b1a700209554be392385934f6c2126210bd76532247a6907d24de0d98d87c
Python
2,244
77
''' IV curves for Fig. 6 (Ciliated cells with 0 and 4 mM KCl) ''' import pandas as pd from brian2 import second, volt, amp, ms from pylab import * import matplotlib.pyplot as plt import numpy as np from file_management import * from os.path import join, split import os width, height = 2,2 overwrite = True table = pd...
42da9269456ebd87dff89e61925a262d4913eed83c2df2a4f7d199e0873938ba
Python
2,246
63
import unittest import torch import numpy as np from torch_geometric.data import Data, Batch from deeprank_gnn.community_pooling import community_detection, community_pooling, community_detection_per_batch class TestCommunity(unittest.TestCase): def setUp(self): self.edge_index = torch.tensor([[0, 1, 1,...
f77c891e4a8e558ec143b6ae81a626666959e2daa7961ae09d6d812e24f372d8
Python
2,247
63
import subprocess BaseCase = __import__('base_case').BaseCase class LoadResultsTest(BaseCase): def test_basic_load_results(self): self.open_main(static=False) #currently nonstatic required filenames = [ "PD_T088_L004_13.11.18_091057_015_SS_crop.tiff", "PD_T088_L0...
0b9b091d4a84054d2e1cde2938c0458b5c65c65d354d5da5d6216ed1c47f6387
Python
2,248
72
# Activation functions import torch import torch.nn as nn import torch.nn.functional as F # SiLU https://arxiv.org/pdf/1606.08415.pdf ---------------------------------------------------------------------------- class SiLU(nn.Module): # export-friendly version of nn.SiLU() @staticmethod def forward(x): ...
22cb5f8b56ee943954b94fc082492029e09f009994421123899f717b790f419b
Python
2,248
59
import torch def build_optimizer(optim_params, cfg): """ Construct a stochastic gradient descent or ADAM optimizer with momentum. Details can be found in: Herbert Robbins, and Sutton Monro. "A stochastic approximation method." and Diederik P.Kingma, and Jimmy Ba. "Adam: A Method for Stochas...
8dabbee1accaa0e11929a6a1267e25fd3650f6c53efc5850d2ac57bc3ba8b098
Python
2,248
68
import os, glob import torch import argparse import numpy as np def aggregate_results(exp_method, metric, level, path): ''' Metrics should match: {exp_method}_{metric}_{level} Also performs filtering for None's Assumes they are each dictionaries (standard usage in Owen's parallelization) ...
e25041537c7337abdd744bb40732c32b65e574f48413892b761d9f7f6e2930d7
Python
2,248
49
import numpy as np import pandas as pd import pcwa as pcwa import matplotlib.pyplot as plt # read the raw mass scpectroscopy data and truth values # df_raw = pd.read_csv('n100sig66_dataset_1_25/Dataset_7/RawSpectra/noisy7.txt',sep=' ') # df_true = pd.read_csv('n100sig66_dataset_1_25/Dataset_7/truePeaks/truth7.txt',sep=...
44a85c92e83aa72badda2787dca290c4d9aac84b4012f7614a17f0826c0a264a
Python
2,249
48
from pycpd import DeformableRegistration, RigidRegistration import numpy as np import time from scipy.interpolate import Rbf import warnings def cpd_non_rigid_transform_pt(pt, Y, G, W): from scipy.interpolate import LinearNDInterpolator interp = LinearNDInterpolator(points=Y, values=np.dot(G, W), fill_value=0....
8c323e69e1c203609bd78db8565cb9d33e45fa643d37d266f311e8e5dc648e3e
Python
2,251
94
import re import numpy as np from scipy.spatial import KDTree # aliasing this import matplotlib.pyplot as plt POS_REGEXP = re.compile(r"\[([0-9]*) +([0-9]*) +([0-9]*)\]") def extract_centroids(df): # old df format # return np.array(list(zip(df.centroid_x, df.centroid_y, df.centroid_z))) return np.arra...
4d9dbbc4da129b8a1bc2e8e36ed0747cdd9e02e24521246a2b3e3402d85bedcb
Python
2,252
53
# 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 a...
7e3b10914a1a30a761154676d13638d34e57e4772e9a86b39a1ed1b1062b6c69
Python
2,253
36
"""Detail-preserving, temporally smoothed Harmonizer merge. The Harmonizer's useful work on an inserted car is low-frequency (tone, shading, edge softening); its high-frequency output jitters from frame to frame. Keep the composite's detail and apply only the low-frequency delta, smoothed over time: out_k = comp_k + u...
1b8e6b1f78c4991cc240081000de6418e639c151402b104a7f2d29bccd285fb8
Python
2,256
59
# 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...
a4f3bb0f5c6f3e0f8c27a47374dd73abd7ce95c3b629714bde37415409d71676
Python
2,258
58
# 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...
794b4825061cf2b39961afbcaeb392a9eeebd07f2e3c119a5ee744126205bee2
Python
2,259
71
# 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...
6de15e71d03eacccd25d07ade342f4ccff4e5186141dbaaec8a4f650eb87c163
Python
2,260
86
import csv import os import sys def feature_to_index(cases, column_nb, offset=0): feature_set = set() for case in cases: feature_set.add(case[column_nb]) l = list(feature_set) index = {} i = 0 for f in l: if f != '': index[f] = i + offset i += 1 retur...
a06acc7be864667a2b7a8322496b17216fd0c7e15e14f558edfe25600908ebd2
Python
2,260
67
import cv2 import torch import numpy as np from torch.utils import data from config import config from utils.img_utils import random_scale, random_mirror, normalize, \ generate_random_crop_pos, random_crop_pad_to_shape class TrainPre(object): def __init__(self, img_mean, img_std): self.img_mean = img...
ce6ad1f49782eba04b3527c98c7f7d1a2757247eeda317d82522e30bbe5b7894
Python
2,261
36
"""Stills on a World Partition map (Town15 by default, MAP=... to change) with a hero vehicle parked under each camera, so the map streams the area. Without the hero a -game server renders only the cells around the spectator start and the shot comes out empty. wp_shots.py OUTDIR "name=x,y,z,yaw,pitch;hx,hy,hz" ......
d89feb62673d51f812180f6f79bf494a0eb26665a30c3aaeb4a59144bb923b52
Python
2,262
65
from tqdm.auto import tqdm from copy import deepcopy import numpy as np # prepare data for kernel regression def prepare_data( df, standardize_features=False, dlight_key="signal_reref_dff_z", sz_cutoff=23 * 30 * 60, feature_variables=[], powers=None, ): szs = df.groupby("uuid").size() ...
b0adb65c8564c4a23075419cf7f2e1d0d9b042d21fb73405c37c0297591af093
Python
2,263
67
# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup -------------------------------------------------------------- # Built...
f2a6b3782b2aff1170b6d4bbf5641dce3f6b42136e747bc9749640eb0ada63db
Python
2,264
79
import sys import numpy as np import circularFiltering as flt from time import time kappa_z_array = np.array([0.01,0.03,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,2,3,4,5,6,7,8,9,10,30,100]) len_kz = len(kappa_z_array) # translate input varibles kappa_star = float(sys.argv[1]) beta = float(sys.argv[2]) sigmaN = float(sys....
07269acfab7d9334fba2443808745f428d3630b7af07046268a898548e237e27
Python
2,265
66
from abc import ABC from typing import Dict, List, Tuple, Iterable, Union from oaklib.interfaces.basic_ontology_interface import BasicOntologyInterface, RELATIONSHIP_MAP, RELATIONSHIP from oaklib.types import CURIE, LABEL, URI, PRED_CURIE from oaklib.utilities.graph.relationship_walker import walk_up class RelationG...
756e3350bb49ad4edfc1ed34af3194cf07d4ce50e7241630da1a1cec7f5376e9
Python
2,265
54
# 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...
adbfafe04e772478f9994bdc65383f6ccf7e906671e2d59e9ae0ec98ff4630f2
Python
2,265
65
""" © 2022, ETH Zurich """ from rdkit import Chem from rdkit.Chem import DataStructs import argparse import os from rescoss_logp_ml.utils import FOLDER_NAMES, PROC_DATA_PATH, DATA_PATH import pandas as pd import numpy as np from tqdm import tqdm import pickle def get_2d_features(smiles_list): from rdkit.Chem im...
ec47b96b1b6f89239f98ac712bfd468141497c41fda30489fb1990b30c89b991
Python
2,266
58
from linkml_runtime import CurieNamespace from oaklib.datamodels.ontology_metadata import slots as omd_slots import oaklib.datamodels.ontology_metadata as omd WIKIDATA = CurieNamespace('wikidata', 'http://www.wikidata.org/entity/') WDP = CurieNamespace('wdp', 'http://www.wikidata.org/prop/direct/') NAMESPACES = [omd.O...
0ffc34134c26b9318a1e3cdf57448ef14d124f025a93c99db0b17caf8869307f
Python
2,267
75
''' Figure 8. Example of reversal asynchrony between anterior and posterior side. 2020-10-12 16.08.21 ''' from brian2 import * import yaml from file_management import * from pylab import * import matplotlib.font_manager as fm import os from os.path import join from fitting import * from plotting import * from mpl_toolk...