sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
9f0e032104b9ad286634ca0bac03645f1860bd90797278b7eb54b981f4bdd78e
Python
1,189
32
"""General Linear Model (GLM) and permutation testing. Modules ------- - :py:mod:`~osl_dynamics.glm.base` — :py:class:`DesignConfig` for specifying regressors/contrasts and :py:class:`GLM` for fitting the model. - :py:mod:`~osl_dynamics.glm.ols` — Ordinary least squares implementation. - :py:mod:`~osl_dynamics.glm.p...
3cae990b1ce4b83ddf58530b6e2962c82b3b38f84e58636608105b6fda08f128
Python
1,191
31
"""Command line interface for Selene. Why does this file exist, and why not put this in ``__main__``? You might be tempted to import things from ``__main__`` later, but that will cause problems--the code will get executed twice: - When you run ``python3 -m selene_sdk`` python will execute``__main__.py`` as a script. ...
96c5b77e40a619805d7ee3dd220b9fdc033c0c1827ca7d9b45283da578a098ef
Python
1,191
53
''' fires_to_geojson.py Convert JSON fires data from NASA FIRMS into GeoJSON format This makes it a lot easier to work with and visualize ''' import glob import json import os input_dir = './fires_v2' output_file = './fires_v2/bali_fires.geojson' input_files = glob.glob(os.path.join(input_dir, '*.json')) print('F...
24e295ef7bb93723fdd39ba6a6f3e6d91470067afe9ea0802b36bff1343eb65b
Python
1,192
39
# %% 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 import pymaid rm = pymaid.CatmaidInstance(url, token, name, password) import connectome_tools.process_matrix as pm import connectome_tools.celltype as ct import navis ...
2187fb37cc23d02862a8caaf05988c0aa3a3201c9cc08951b517af7a695d04a1
Python
1,193
47
from abc import ABC from dataclasses import dataclass from typing import Optional from oaklib.implementations.sparql.abstract_sparql_implementation import AbstractSparqlImplementation from oaklib.interfaces.mapping_provider_interface import MappingProviderInterface from oaklib.interfaces.obograph_interface import OboG...
3eeb8a70ab8020ee5e77f3ae84d1eab3e51b078d89fd1fb9b9b8820dc1a1059b
Python
1,193
41
# Copyright (c) Open-MMLab. All rights reserved. from collections import OrderedDict import numpy as np class LogBuffer: def __init__(self): self.val_history = OrderedDict() self.n_history = OrderedDict() self.output = OrderedDict() self.ready = False def clear(self): ...
dc5efbccf36efefdb67805729c7081c97eb0b994811c2be0a91ec799297d7ad6
Python
1,193
46
import lxml.etree as ET import sys import re import os def main(): #DEBUG #import pydevd #pydevd.settrace('10.211.55.3', port=4200, stdoutToServer=True, stderrToServer=True) # Read XML xml = ET.parse(sys.argv[1]) try: # Get the xml schema version schemaURI = xml.getroot().get...
4b5b2fdf41c62adfa3d8d50d4ffc19c8531c7d698a02831c84e56a55d4bd959e
Python
1,194
32
import os import synapseclient import synapseutils import argparse import getpass parser = argparse.ArgumentParser(description='Download RNAseq and genotypes of CMC.') parser.add_argument('RNAseq_directory', help='Directory to download RNAseq data to') parser.add_argument('Genotype_directory', help='Directory to downl...
5e86242a7c8a5471d677f7ffe6e47eddb1d458f633e93616b7cc94234c41cfcd
Python
1,195
36
import pytest import numpy as np from numpy.testing import assert_almost_equal, assert_array_almost_equal from pycpd import affine_registration def test_2D(): B = np.array([[1.0, 0.5], [0, 1.0]]) t = np.array([0.5, 1.0]) Y = np.loadtxt('data/fish_target.txt') X = np.dot(Y, B) + np.tile(t, (np.shape(Y)...
c08e8cde029ecbf37336fd59f3daa6eaa6434ebd370d45c4bd155f7bad57c33d
Python
1,196
35
from functools import partial import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from pycpd import rigid_registration import numpy as np import time def visualize(iteration, error, X, Y, ax): plt.cla() ax.scatter(X[:,0], X[:,1], X[:,2], color='red', label='Target') ax.scatter(Y[:,0], ...
805566a6ba90db2a7bdbb24a3d1782f4bc4f0c5b7775433439e691888005f6f3
Python
1,197
33
''' Plot geometry & output forces (exerted by cilia on the fluid) & velocities. Visualizing forces and velocities is tricky: We want to average over several nearby points, otherwise we have too many arrows Right now, I just average over one-dimensional indices -> works for cilia. Applying this code to other geometries...
66bb7f9beee12ed82d1c0e62085f4fa4ce7eed8605c16eeb8308c66b87519a7a
Python
1,198
38
from PyQt5.QtCore import QThread, pyqtSignal from PyQt5 import QtNetwork # ---------------------------------------------------------------------------- class TcpServer(QThread): """ Defines the thread listening to the go signal from MATLAB. """ tcpsignal = pyqtSignal(str) def __init__(self, port=823...
9f9b11840ed28414c6dffa407bd58ee992f8d43b4554755ec13ea4507f229976
Python
1,198
61
__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 class Select: """ A class for selecting chains and pockets in PyMOL. Attributes ---------- Non...
cf1a5bf5c155e42bb3c95e0089e9c357e0bdca65fce618f279f0ba9e92a98117
Python
1,199
35
""" © 2022, ETH Zurich """ from rescoss_logp_ml.predict_with_trained_model import predict_with_trained_model from rescoss_logp_ml.utils import ROOT_PATH, DATA_PATH, MODEL_FILENAMES import os import pandas as pd import numpy as np import pytest import itertools TEST_FIRST_N = 10 # faster tests and just want to check...
ed2cda93c310b623f581da7dc6fc1fadfb558d3c5eabdf90d543630422176abe
Python
1,199
38
import sys, numpy as np #from matplotlib import pyplot as plt infile = sys.argv[1] outfile = sys.argv[2] tr = {} rec = [] with open(infile) as f: for i in f: i = i.strip().split("\t") if any(s in i for s in ['motif', 'zscore', 'end', 'start']): header = i else: de...
5d55be17ea844ba91577f8ae105596ba45d88e78538cc8c3ab76a2cca8c9120f
Python
1,200
42
import os.path import tempfile from unittest import TestCase from drugex.data.corpus.corpus import SequenceCorpus from drugex.data.corpus.vocabulary import VocGraph from drugex.molecules.converters.standardizers import DefaultStandardizer from drugex.molecules.suppliers import StandardizedSupplier class CorpusTest(T...
14dee3badd47e975704d4595488be0720b99f0f016b6c506c93a036d2250178a
Python
1,201
54
"""Get inferred parameters. """ from sys import argv if len(argv) != 3: print("Please pass the number of states and run id, e.g. python 3_get_inf_params.py 8 1") exit() n_states = int(argv[1]) run = int(argv[2]) #%% Import packages import os import pickle import numpy as np from glob import glob from osl_d...
a6aaa411241615a8abdf4fdbaa1de0c6a2e0446f8cad52111f629dd23a9df8bd
Python
1,202
30
import sys import torch from torch_geometric.datasets import TUDataset from graphxai.explainers import PGMExplainer #from graphxai.explainers.utils.visualizations import visualize_mol_explanation from graphxai.gnn_models.graph_classification import train, test from graphxai.gnn_models.graph_classification.gcn import G...
bc4f3c9443c44205bc7102904da068bef37f6cca2cc10dd2d327d5d294c78f87
Python
1,203
48
__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") luascript = snakemake.params.get("lua_script") if luascript: luascriptprefi...
e4454b622cd530f0c364a816da395792e588cd22435f2c0b1094ebadf4cfcd61
Python
1,203
24
#################################################################################################### # 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 ...
068fa299006e83817e121e37c0a2bd3b725b1abdbffe87b8580e48873b24a22c
Python
1,204
55
""" Contain some simple helper functions """ import os import shutil import torch import random import numpy as np def mkdir(path): """ Create a empty directory in the disk if it didn't exist Parameters: path(str) -- a directory path we would like to create """ if not os.path.exists(path)...
46e7bb4d7382ee4c2599c49be3ad0394c8fcc5ffa29814894d40fdbc3ebc7495
Python
1,204
54
"""Plot results. """ #%% Run ID and output directories import os from sys import argv # We get the run ID from the command line arguments if len(argv) != 2: print("Please pass a run id, e.g. python 5_plot_results.py 1") exit() id = int(argv[1]) # Check results directory exists results_dir = f"results/run{i...
a461d7d5df191156566558e4fd1c4d701eb7e161ee5d01763f4704fc36f3b336
Python
1,204
36
import torch from torch import nn class IOULoss(nn.Module): def forward(self, pred, target, weight=None): pred_left = pred[:, 0] pred_top = pred[:, 1] pred_right = pred[:, 2] pred_bottom = pred[:, 3] target_left = target[:, 0] target_top = target[:, 1] targ...
e0b83f83d0609a12d8a462624546ed049770c7591aeb41a2c443c609a57beafe
Python
1,204
49
#%% import numpy as np import pandas as pd from pathlib import Path # %% decon_results = Path("./res/") # %% dfs={} for file in decon_results.glob("decon*.csv"): dfs[file.stem] = pd.read_csv(file,index_col=0) # break # dfs.append(pd. # %% all_decon_df = pd.concat(dfs) # %% all_decon_df.index.names = ["fil...
ca6cede6b9cae1d00d9eaeb8a3ee0df1b0dd23ebfec735913a89b3e4db16bf24
Python
1,206
62
import json import thulac from sklearn.externals import joblib class Predictor(object): def __init__(self): self.tfidf = joblib.load('predictor/model/tfidf.model') self.law = joblib.load('predictor/model/law.model') self.accu = joblib.load('predictor/model/accu.model') self.time = joblib.load('predictor/mod...
ab26a6b4c55c542efb7562844f8faa0e46e58af227d60d61f088d9b22023b035
Python
1,207
43
import os import nibabel as nb import numpy as np import zipfile TEMP_UNZIP_PATH = '/mnt/EncryptedData1/Users/javier/ext_datasets/LITS17/temp' NII_EXTENSION = '.nii' def save_nifti(data, save_path, header=None, verbose=True): if header is None: data_nifti = nb.Nifti1Image(data, affine=np.eye(4)) els...
42a41a9e58bd7160c31d910e3afc36a6cd10cbc754743759080fc5b0b692513f
Python
1,208
34
# 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...
9103aade06a097c203e14601785f5993127d496f8d6613031f90e34288098320
Python
1,208
30
import AIS_neighbors import AIS_geopandas_tagging import pandas as pd import import_AIS import functions_basic_sak as funsak import trajectory from tqdm import tqdm from skimage import data, util, measure from scipy.ndimage.measurements import label import AIS_parameters pd.set_option('display.max_columns...
2592fe022dceff0597f49c988f22d03693ad84d5ec9fd432e044e7984f87b7f2
Python
1,209
44
import torch import os from graphxai.datasets.load_synthetic import load_ShapeGGen from graphxai.datasets import ShapeGGen from graphxai.utils.explanation import Explanation #SG = load_ShapeGGen('data/ShapeGGen/new_unzipped/SG_homophilic.pickle', root = '/Users/owenqueen/Desktop/HMS_research/graphxai_project/GraphXAI'...
b570173da003cba62951b413e2102393197aa051047e8b5e22ad1dcd0343684f
Python
1,209
50
from __future__ import print_function import sys import struct def create_index(tfrecord_file: str, index_file: str) -> None: """Create index from the tfrecords file. Stores starting location (byte) and length (in bytes) of each serialized record. Params: ------- tfrecord_file: str P...
bd86d06efd2176c85abcbdb58e6b0c632d23194b3fbee06142bbad37fef6c827
Python
1,209
37
import unittest from linkml_runtime.dumpers import yaml_dumper from linkml_runtime.utils.introspection import package_schemaview import oaklib.datamodels.validation_datamodel as vdm from tests import output_path class TestValidationDatamodel(unittest.TestCase): def test_create(self): """ Tests ...
e676b1cd6dc3a9042c18854e4d8d121c0d9fcb65d51d65fe5dd18128561b7297
Python
1,209
35
import torch from norse.torch import LIFAdExState def save_states(x, save_states: bool, layer, state, additional_current=None): if additional_current is not None: if additional_current.shape[0] == 1: tmp_additional_current = torch.zeros( (len(x), additional_current.shape[1]) ...
5f20d399489f94d91423a89c5729cd483db5d88858c498357b470f73f3bc0af1
Python
1,212
32
import torch from torch_geometric.data import Data def train(model: torch.nn.Module, optimizer: torch.optim.Optimizer, criterion: torch.nn.Module, data: Data, losses: list = None): model.train() optimizer.zero_grad() # Clear gradients. out = model(data.x, data.edge_index) # Perform a single fo...
46934d3361955c538fdc2135bbb4f0b2dd3d45b9afee84b8f06a8a515a7b6ce5
Python
1,213
34
import json import unittest import curies from linkml_runtime.loaders import json_loader from ndex2 import create_nice_cx_from_file from oaklib.converters.obo_graph_to_cx_converter import OboGraphToCXConverter from oaklib.datamodels.obograph import GraphDocument from oaklib.interfaces.basic_ontology_interface import ...
a031da47a95bf5d94fff1b3f22c69021f76d52213c4fa02953ccb4ed5364d0d1
Python
1,213
28
# 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...
e58b157dd4c748dd54b5d4523defee9ae583d15d525f13a6f75cdf90947543c1
Python
1,213
31
# 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...
59e1f7efc935932ed698d66f147e140fbb78a05c3abdf03d179e776f22ec5098
Python
1,214
52
import matplotlib.pyplot as plt import numpy as np import seaborn as sns tasks = [ "RomoTask1", "RomoTask2", "DMTask1", "DMTask2", "CtxDMTask1", "CtxDMTask2", "GoTask1", "GoTask2", "GoRtTask1", "GoRtTask2", "GoDlTask1", "GoDlTask2", ] # cmap = sns.cm.magma def main():...
86050bd9113de33bebd43bf1735abcfc1536c6ae0fe5ffda1136ffb2ee3d36d7
Python
1,214
39
import random import torch from graphxai.explainers import GraphLIME from graphxai.explainers.utils.visualizations import visualize_subgraph_explanation from graphxai.gnn_models.node_classification import BA_Houses, GCN, train, test n = 300 m = 2 num_houses = 20 bah = BA_Houses(n, m) data, inhouse = bah.get_data(nu...
beb7c00a35a6c52c35e698a77f806515bcf48f576d77b6b34d13d55a1e904576
Python
1,214
44
import torch import os from graphxai.datasets.load_synthetic import load_ShapeGGen from graphxai.datasets import ShapeGGen from graphxai.utils.explanation import Explanation #SG = load_ShapeGGen('data/ShapeGGen/new_unzipped/SG_homophilic.pickle', root = '/Users/owenqueen/Desktop/HMS_research/graphxai_project/GraphXAI'...
d76c50a7e9ebbb37b44a0a57ee62a8b605a6c7568863f26ec68a008223c1d40f
Python
1,214
21
# Copyright (c) Open-MMLab. All rights reserved. from .colorspace import (bgr2gray, bgr2hls, bgr2hsv, bgr2rgb, bgr2ycbcr, gray2bgr, gray2rgb, hls2bgr, hsv2bgr, imconvert, rgb2bgr, rgb2gray, rgb2ycbcr, ycbcr2bgr, ycbcr2rgb) from .geometric import (imcrop, imflip, imflip_...
dd6d0f3079a24179be399192f19364dd137b7c386d6fa3e8063faaae89b1cdc1
Python
1,215
38
# 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 ast import os import unittest REPO_ROOT = os.path.abspath( os.path.join(os.path.dirname(...
ee6a5ee6a7b6055978e1b58a4fac0dcf51042e34d609f80b82e5a6267d798cf1
Python
1,216
28
from snakemake.shell import shell log = snakemake.log_fmt_shell(stdout=True, stderr=True) with open(snakemake.log[0], "w") as f: sys.stderr = sys.stdout = f family = snakemake.wildcards.family sample = snakemake.wildcards.sample ref_cache_cmd = "export REF_CACHE={snakemake.params.ref_cache}; export...
2d7fd89676ec579bad9fbbe5c6c37724243ee8c66b48dc3e1d6ab408aadf4989
Python
1,217
41
''' Fix anterior and posterior positions in the morphology file, based on PIV. Anterior and posterior ends picked by eye are swapped to be consistent with swimming direction. This requires prior PIV analysis. ''' import numpy as np from file_management import * import sys from scipy.stats import circmean from os.path i...
c56520e4e8b6856ad50e1dd20325ca8d64b9b1db67650707f175f7770f958d2c
Python
1,217
37
import torch from norse.torch.functional.lif_refrac import LIFRefracParameters, LIFRefracState from cgtasknet.net.lifrefrac import SNNLifRefrac def test_init_lif_refrac(): input_s, hidden_s, output_s = 100, 100, 100 SNNLifRefrac(input_s, hidden_s, output_s) def test_set_custom_params_lif_refrac(): inpu...
be1321463a1622f3e1d592c49e7108fad51856a83160082ab3406ffc68126fa3
Python
1,218
40
import pandas as pd import numpy as np import os results_path = 'results/' ignore_folders = ['task1_hparams'] resultfolders = [rf for rf in os.listdir(results_path) if rf not in ignore_folders] for rfolder in resultfolders: exppath = os.path.join(results_path, rfolder) endname = 'metrics_test.csv' csvfi...
3292e8d47eb71b59105ae9535296750d2058def4677d7b576146795940f84c4e
Python
1,219
36
import neighbors import loitering import old_ports import elevation import coast_distance import shipping_routes import pandas as pd import functions_basic_sak as funsak import trajectory from tqdm import tqdm from skimage import data, util, measure from scipy.ndimage.measurements import label pd.set_opti...
3d213844cae5ae71898ff44a13f812e41ffd7cf6a3da7e113c5d3825646876bf
Python
1,219
39
#!/usr/bin/env python # Copyright 2016 Allen Guo # 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 # # THIS CODE IS PROVIDED *AS IS* BASIS, WITH...
61b4b6aaf03fefcfe61e51a6eafff66109d274d9cea0dd37315554ef4b476150
Python
1,220
28
# 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...
7b3b70459614a0020817d66a91acaeff091632179251bf071c89bf2f313cd004
Python
1,221
28
from qiskit import * from functions import * from datetime import datetime #Load dictionaries from pkl files to reproduce the plot as shown in the article #Running this script required 1.3sec on a MacBook Pro with a 2.3GHz Quad-Core processor and 16 GB of RAM starttime = datetime.now() toymodelpath = "./toyBNQuantum....
45201b959c41b221ca09007b348a41b981d54642481992f37d31076e49ba3a79
Python
1,222
41
import mne import pandas as pd def save_annotations_csv(raw: mne.io.Raw, save_file_path: str): """Saves annotations of given mne.io.Raw object to save_file_path as .csv file. Args: raw (mne.io.Raw): Raw object holding EEG data. save_file_path (str): Path at which to save annotations file. ...
5f7a41314dcd5181daae744457659df1dfe1a2abdcb089872408522bfeed0ed6
Python
1,222
31
import torch from os.path import join import glob from gssc.train.DataManage import PSGDataSet ### basic example of how to make a PSG Dataset object for use in training, etc. # define where the MNE -raw.fif files are, and also where the resulting output # files will be saved. proc_dir = "/your/directory/path" # where...
8d2579d1cedb7d21f080bf49e75d0df1e562b1b0b9631cce47f4e894ac5c2de8
Python
1,222
39
import logging import unittest from oaklib.implementations import SqlImplementation from oaklib.resource import OntologyResource from oaklib.utilities.mapping.cross_ontology_diffs import ( calculate_pairwise_relational_diff, ) from tests import EXTERNAL_DB_DIR DB_FOLDER = EXTERNAL_DB_DIR / "unreciprocated-mapping...
c22594172dfd88bc660a9eb6ca3db5ceb49ba69d955d23ba250cf565994ba457
Python
1,222
27
#################################################################################################### # 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 ...
285ba881bf9c7300f5540ae826cd1d1bb52df239522811a9263cd1269a3ec459
Python
1,223
43
#!/usr/bin/env python import unreal import argparse import json import os import subprocess """Generic function for running a commandlet with its arguments.""" ue4_path = os.environ["UE4_ROOT"] uproject_path = unreal.Paths.project_dir() + ("CarlaUnreal.uproject") run = "-run=%s" % ("GenerateTileCommandlet") print("B...
c84012af5b9efdebc6c6dc18957aa2db52a3514dcba028c9527ac07c94ab3026
Python
1,223
39
from __future__ import print_function #!/usr/bin/env py # Converts a romanized ECA word list (symbol table) to # a version in the arabic script import sys import codecs if len(sys.argv) < 3: print("USAGE: local/convert_symtable_to_utf.py [SYMTABLE] [ECA-LEXICON]") print("E.g., local/convert_symtable_to_utf.p...
d73794901173aa7a197350223ffbae9256330a02ac623f9868cc21259d121bc0
Python
1,223
30
from ddmr.utils.nifti_utils import save_nifti from tqdm import tqdm import os import h5py import ddmr.utils.constants as C DATASET_LOCATION = '/mnt/EncryptedData1/Users/javier/vessel_registration/3Dirca/dataset/EVAL' DATASET_NAMES = ['Affine', 'None', 'Translation'] DATASET_FILENAME = 'volume' if __name__ == '__main...
1eb83bcc5e03a8a6a818893e6f2a1f3622a17cad2a6a348b8a514a245076ce6e
Python
1,224
32
from Bio.PDB import * # Exclude disordered atoms. class NotDisordered(Select): def accept_atom(self, atom): return not atom.is_disordered() or atom.get_altloc() == 'A' def extractHelix(helix, infilename, outfilename, chain_ids=None, includeWaters=False,\ invert=False): pa...
3b20aaa431a8cf6bb38199175fe46ae7fe31456815770f2378863489e980b5c0
Python
1,224
43
import torch.nn as nn class GramMatrix(nn.Module): def __init__(self): super(GramMatrix, self).__init__() def forward(self, x): b, c, h, w = x.size() feature = x.view(b, c, h * w) feature_t = feature.transpose(1, 2) gram = feature.bmm(feature_t) b, h, w = gram....
abd4bf61ed3ef2655cb92d472bea3189a0aa6d12a256bd86ef26de9c78acb602
Python
1,224
33
from setuptools import setup setup(name='hd_gliomouse', version='1.1', packages=["hd_gliomouse"], description='Tool for brain tumor segmentation in mice. This is the result of a joint project between the Department of ' 'Neuroradiology at the Heidelberg University Hospital and the ...
eb007123339f3b269579ca73c4d452aae49ee76673fa5c3948631f054154c3a9
Python
1,224
43
import os import numpy as np import sys from SBI.structure import PDB from default_config.masif_opts import masif_opts in_fields = sys.argv[1].split("_") pdb_id = in_fields[0] if not os.path.exists(masif_opts["ligand"]["ligand_coords_dir"]): os.mkdir(masif_opts["ligand"]["ligand_coords_dir"]) # Ligands of inter...
f6e330fd506db69e912114288565809c6b28350ca5e94888630a3a329310c6eb
Python
1,224
29
### # #%L # Triangulated surface for deforming in 3D. # %% # Copyright (C) 2013 - 2023 University College London # %% # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, incl...
2235863c97156bdae9e3c5862b2e4d2192dfe55b04b0d738ce732c4dec8a2a8a
Python
1,225
36
import unittest from linkml_runtime.dumpers import yaml_dumper from linkml_runtime.utils.introspection import package_schemaview from oaklib.datamodels import obograph from oaklib.datamodels.vocabulary import IS_A from tests import output_path class TestOboGraphDatamodel(unittest.TestCase): def test_create(self...
929a93630b0aeed6026ba480071bdd981f15aa8614fb4f54e77fda41c5a664bf
Python
1,225
41
from typing import Any, List, Optional from zencfg import ConfigBase from ..distributed import DistributedConfig from ..models import ModelConfig, FNO_Medium3d from ..opt import OptimizationConfig, PatchingConfig from ..wandb import WandbConfig class MHD64OptConfig(OptimizationConfig): n_epochs: int = 600 le...
d184e84fdd3c4eaf7c6a5cd84e057135b936521295f0734ee086bc4dac68a7aa
Python
1,226
48
import argparse import os.path as op from glob import glob import pandas as pd def _get_parser(): parser = argparse.ArgumentParser(description="Get subjects to download") parser.add_argument( "--dset", dest="dset", required=True, help="Path to fMRIPrep directory", ) pa...
e612ac33a5fb8ea0ccd3af65df48dc0f49b3176ea692b19e52dda61beb5672a6
Python
1,226
36
# python 3.7 """Helper functions.""" from .model_settings import MODEL_POOL from .stylegan_generator import StyleGANGenerator from .stylegan_encoder import StyleGANEncoder from .perceptual_model import PerceptualModel __all__ = ['build_generator', 'build_encoder', 'build_perceptual'] def build_generator(model_name,...
fc3cd58105ef89ad5584890e7f4e135722de78941d3b6dc851d789e8ad4b0323
Python
1,226
37
import torch.nn as nn from tools.utils import parse_net_config, sort_net_config from .operations import OPS, conv_bn class Block(nn.Module): def __init__(self, in_ch, block_ch, ops, stride, use_se=False, bn_params=[True, True]): super(Block, self).__init__() layers = [] for i, op in enum...
1da217cea720eb44e197e59ca737f0f1a67dfea5aa19795d578469747cde7031
Python
1,229
34
# -*- 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) """ from PIL import Image import os import numpy as np def split_class(pred_path, img_name,...
ad356d66b69f3bdd7de399315a0f69fd53e2f3f61c2f93c6450fa6a32d77aae8
Python
1,229
50
''' 2021-03-12: separate geometry and physics in order to have 1 geometry file for different frequqncies sets ''' import numpy as np import carpet import carpet.lattice.triangular as lattice ## Parameters # Geometry nx = 16 ny = 16 # even number N = nx * ny a = 18 # [um] lattice spacing ## Initialize # Geometry d...
32c80b2079f41c7ea54bcd86905a4b9c30587b0dc6be255c9bba6cc04854e111
Python
1,230
47
from setuptools import find_packages, setup setup( name="rl_analysis", packages=find_packages(), version="1.0.0", platforms=["mac", "unix"], description='Python package and notebooks corresponding to "Spontaneous behavior is structured by reinforcement without explicit reward"', author="wingill...
aabe0ced3abf8d1115da0a7c8f8e4b67b1f7417fb5341df5e879bb95612f4f5a
Python
1,230
40
import os import warnings warnings.simplefilter(action='ignore', category=FutureWarning) import numpy as np from subprocess import Popen, PIPE from IPython.core.debugger import * import sys from Bio.PDB import * import pyflann # Go to directory struct_dir = 'pdbs/' trans_output_bin = "/home/gainza/lpdi_fs/seeder/data...
15031b0102651df9ba883df74624e82e566d04feb1b31ad402dbe7bf3a2b3d94
Python
1,231
40
from typing import Any, List, Optional from zencfg import ConfigBase from .distributed import DistributedConfig from .models import ModelConfig, FNO_Medium2d from .opt import OptimizationConfig, PatchingConfig from .wandb import WandbConfig class NavierStokesOptConfig(OptimizationConfig): n_epochs: int = 600 ...
ac44682f01e36c3fc0155ec315c5d8c3898fbef984529edff44638e56179efc2
Python
1,231
30
import numpy as np from scipy.stats import beta, chi2 from scipy.stats import combine_pvalues as scipy_combine_pvalues from scipy.stats import ks_1samp, uniform def combine_pvalues(pvalues, method="fisher"): pvalues = np.array(pvalues) scipy_methods = ["fisher", "pearson", "tippett", "stouffer", "mudholkar_g...
ad1a4a9e6cc791c34ba7d6a2555f3355603caf18abea6a40784915accf6b1193
Python
1,231
28
from setuptools import setup long_description = """A library that provides feature importances, based upon the permutation importance strategy, for general scikit-learn models and implementations specifically for random forest out-of-bag scores. Built by Terence Parr and Kerem Turgutlu. See <a href="http://explained.a...
4fd4255565fb06acaeb46bf430f6848e5db7774be048c734d99a174a8898dfd2
Python
1,232
53
#%% IMPORT MODULES from __future__ import division import os import pickle from grr.cell_class import Cell from grr import MiniDetector #%% LOAD DATA DATA_PATH = os.path.join('data', 'raw', '5HT', 'GABA_synapses') mIPSC_fnames = ['18o23003.abf', '18o23004.abf', '18o23005.abf'] mini_recs = Cell().read_ABF( [o...
cfde08a1ad836127ee3157e6ddb0b1c5fe036818ab6ec13c843c791a5a2a36c5
Python
1,233
28
from argparse import ArgumentParser from mmdet.apis import inference_detector, init_detector, show_result_pyplot def main(): parser = ArgumentParser() parser.add_argument('--img', help='Image file') parser.add_argument('--config', help='Config file',default='./configs/mask_rcnn/mask_rcnn_r101_fpn_1x_coco...
5aaa89ffc1022fb79a10584035eb021c9ae05c73ab35f8dd7861bfcdaeba4cf1
Python
1,236
50
# 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 a...
69d1bc0b5bb0d34bc98457bc170f8541270304f13ba25c5984243a831bd27b33
Python
1,237
41
import torch from torch.autograd import Variable import numpy as np import collections __all__ = ['as_variable', 'as_numpy', 'mark_volatile'] def as_variable(obj): if isinstance(obj, Variable): return obj if isinstance(obj, collections.Sequence): return [as_variable(v) for v in obj] elif i...
d93550a7e0641172893aa058d3a8dbee40bc0d7d9a55f7ee7d9c84d85e8f31ee
Python
1,237
32
import torch.nn as nn class ConvNorm(nn.Module): def __init__(self, in_channels, out_channels, kernel_size=1, stride=1, padding=None, dilation=1, bias=True, w_init_gain='linear'): super(ConvNorm, self).__init__() if padding is None: assert(kernel_size % 2 == 1) ...
eaf07c342bc8342bc11d742b3c9cfc6ffb6bdce0744c7df1bb21382fb512baa8
Python
1,239
24
from .base_roi_head import BaseRoIHead from .bbox_heads import (BBoxHead, ConvFCBBoxHead, DoubleConvFCBBoxHead, Shared2FCBBoxHead, Shared4Conv1FCBBoxHead) from .cascade_roi_head import CascadeRoIHead from .double_roi_head import DoubleHeadRoIHead from .dynamic_roi_head import DynamicRoIHead fro...
0e04589476554a459cd6c3c82b3c203ce38f5981259002f11cf5e0dab5eb122e
Python
1,240
30
from snakemake.shell import shell log = snakemake.log_fmt_shell(stdout=True, stderr=True,append=True) family = snakemake.wildcards.family outdir = snakemake.params.outdir tool = snakemake.params.tool pythonpath = tool.replace("bin", "") python = " export PYTHONPATH={pythonpath}; " # Temporary fix until mity fixes b...
fc51b6d5f5764d394869fb19f35046dd6f2896773f6b56633adcad2c07868ff9
Python
1,240
41
# -*- coding: utf-8 -*- # @Author : WenHan import numpy as np from models.net_q import QMyFuseModel from sklearn.metrics import accuracy_score, f1_score, confusion_matrix from tqdm import tqdm # This script should be only used for quantized performance evaluation! # To test the inference speed, please use tst_keras_...
21956c8444285f4e43646f63e6741367c5a4ce77f7542b87b88f7101b35ff31a
Python
1,241
33
import argparse import os import torch if __name__ == '__main__': parser = argparse.ArgumentParser(description='Convert MoCo Pre-Traind Model to DEiT') parser.add_argument('--input', default='', type=str, metavar='PATH', required=True, help='path to moco pre-trained checkpoint') ...
85f32696e8b90447323cb589d4bfae81165205922fbe3bb014d8d9c31c437373
Python
1,241
46
# %% # import pandas as pd import numpy as np import seaborn as sns import matplotlib.pyplot as plt import networkx as nx from joblib import Parallel, delayed from tqdm import tqdm from pymaid_creds import url, name, password, token import pymaid import connectome_tools.cluster_analysis as clust import connectome_too...
a53f043fd893c6b73a7443c00ab1b9f1529bace4e468647803a7a655976b8004
Python
1,242
42
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 DarcyOptConfig(OptimizationConfig): n_epochs: int = 300 learnin...
0b9becf01b38914a0d140573d0e403ec95199a7adad1ea2d7cb1441b9d9f79a7
Python
1,243
43
import numpy as np def cm2inch(*tupl): """ Convert centimeter tuple to inch tuple for setting figure size in matplotlib """ inch = 2.54 if isinstance(tupl[0], tuple): return tuple(i/inch for i in tupl[0]) else: return tuple(i/inch for i in tupl) def remove_box(ax, type = 'vert...
85b8ee3cce2a8645df84e1b567a4dede3788fa321927e933deddf742bd52c4db
Python
1,245
38
# 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...
0a44f506c5015a3fc439d33fe455099f6c295afd681e7b9b3ea1d44288718d5b
Python
1,246
45
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import unetsl.model import unetsl.data import skimage.draw import sys import numpy if __name__=="__main__": print("usage: box_detect_bristles.py model.h5 input.tif output.tif") img, _ = unetsl.data.loadImage(sys.argv[2]) model = unetsl.model.loadModel(sys.ar...
e3b8e34e112afb74099d4434fbe17025217d083c0d567f5585a7ff2eacd0b722
Python
1,246
42
import lib import numpy import theano import theano.tensor as T import lasagne # from theano.compile.nanguardmode import NanGuardMode import math import time import locale locale.setlocale(locale.LC_ALL, '') def print_params_info(params): """Print information about the parameters in the given param set.""" ...
6334cad96e56916397932048ce2d4c86cce85c6d95c26ea3a050037b5fc1abda
Python
1,247
40
#!/usr/bin/env python # coding: utf-8 # # Author: Kazuto Nakashima # URL: https://kazuto1011.github.io # Date: 19 February 2019 from __future__ import absolute_import, print_function import torch import torch.nn as nn import torch.nn.functional as F from .resnet import _ResLayer, _Stem class DeepLabV1(nn.Sequ...
ae754d17213b3c6d374e18861a5bb8726f25958abeac23994c59091814a880d8
Python
1,247
48
import matplotlib.pyplot as plt import numpy as np import seaborn as sns tasks = [ "RomoTask1", "RomoTask2", "DMTask1", "DMTask2", "CtxDMTask1", "CtxDMTask2", "GoTask1", "GoTask2", "GoRtTask1", "GoRtTask2", "GoDlTask1", "GoDlTask2", ] # cmap = sns.cm.magma def main():...
5c58e2e7e6bf0c75c57126d288e30f652d76dcb16c4dbaf33b284dfff44ce2df
Python
1,248
39
import numpy as np # import mpmath as mp def ntf_laplace(C,L1,L2,Tau,nroi,alpha,tau_e,tau_i,tauC,gei,gee,gii,s,noisein,trange,nr,dt): nroi = C.shape[0] K = nroi # Cortical model Fe = np.divide(1 / tau_e ** 2, (s + 1 / tau_e) ** 2) Fi = np.divide(1 / tau_i ** 2, (s + 1 / tau_i) ** 2) Hed = (1...
e4dd0a7c79cc9a319dd3ce654e44650759ef78664b177cd0e18d284b18589eb1
Python
1,248
50
''' Bring together data from multiple sessions with optogenetic testing of vowel discrimination in noise by F1706_Mimi Tested in white elephant with sounds in restricted noise only, varying vowel in level and thus SNR. ''' from datetime import datetime import pandas as pd from pathlib import Path parent_dir = P...
7b7ef85ed28a3ef3848336f487c8bde350eda1daf34be62aa5f6d1035b411da5
Python
1,249
37
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. import os from maskrcnn_benchmark.utils.imports import import_file def setup_environment(): """Perform environment setup work. The default setup is a no-op, but this function allows the user to specify a Python source file that performs ...
b75394d758f22e8ad2ec51884e705958947a4d5c601a7c1a6428271dfe81589a
Python
1,249
35
import torch import torch.nn as nn class Dropped_Network(nn.Module): def __init__(self, super_model): super(Dropped_Network, self).__init__() # static modules loading self.output_indices = super_model.output_indices self.sub_obj_list = super_model.sub_obj_list self.alphas_n...
8f2bfe61ab3a5ca927d66c4d49fab316c5d26d9eaf19690c42746645e4064a9e
Python
1,250
37
from dataclasses import dataclass from ontoportal_client import BioPortalClient from oaklib.implementations.ontoportal.ontoportal_implementation_base import ( OntoPortalImplementationBase, ) @dataclass class BioPortalImplementation(OntoPortalImplementationBase): """ A :ref:`OntoPortal` implementation th...
a24706b6135d48f62a924f6353c339b2eddd55cea8621c67ff435d5c125ece1e
Python
1,250
44
#!/usr/bin/env python # Keep track of the best value we're seen so far in a series of calls. # This is pretty elaborate. But this way we're got all the gubbins in # one place, and the calls to it in the main body of the program are # simple. The parent script was starting to fill up with "find the # best one" clutter...
3b02850c499a00c64755d08bd5bcaf9fe320d11afde8c0b18d156c49e98d72c7
Python
1,251
24
# 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...
ed07dddef5d1920cfd3be9a55569fb4a0851483ff32e41c7c471ec1d2d18f036
Python
1,251
42
# Copyright 2021 Xiaomi Corporation (Author: Junbo Zhang, Yongqing Wang) # Apache 2.0 # This script does phone-level pronunciation scoring by GOP values. import sys import argparse import pickle import kaldi_io from utils import round_score def get_args(): parser = argparse.ArgumentParser( description=...
4d606a24fbcfe9ae7272a1f2c499881b45171b93a95c387d5d8a69dded2851af
Python
1,252
28
# 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...
a4e098fa8ad8ca6a6decf74a4620f3961f81ab32d41a9bb6cc93e579cce552e3
Python
1,253
53
# -*- coding: utf-8 -*- """ Created on Fri Feb 18 13:00:49 2022 @author: csb """ import pandas as pd import seaborn as sns import matplotlib.pyplot as plt sns.set_theme(context='notebook', style='ticks',font='arial',font_scale=1.2) #%% Bistable data=pd.read_csv('Bistable.csv') f, ax = plt.subplots(figsize=(5,4)...