sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
f7916f6cc661fe0faef259b959df96c4d99718e0bd1b5f3f2b7972e9faf8da1b
Python
2,247
59
import nibabel as nib import numpy as np import matplotlib.pyplot as plt def load_image_masked(img_filename, im_threshold = 15): orig = nib.load(img_filename) zoom = orig.header.get_zooms() if len(zoom) == 4: zoom = zoom[:-1] orig_data = orig.get_fdata() mask = orig_data > im_threshold ...
64010bcf485b69b9158b3f979f585c654b4ab664d386d42d7abc1ad006c9cab8
Python
2,249
61
"""PyTorch Dataset wrappers for non-graph molecular representations.""" from typing import List, Optional, Tuple import numpy as np import torch from torch.utils.data import Dataset class FingerprintDataset(Dataset): """Dataset wrapping fingerprint arrays and target values. Shape contract --------------...
cb993b205ec6812312fa7c48a70a7569fe0e6d93247984690456aaf1028d9129
Python
2,252
95
"""This tests the CLI functionality of predicting with a callback. """ import json import pytest from chemprop.cli.main import main pytestmark = pytest.mark.CLI @pytest.fixture def data_path(data_dir): return str(data_dir / "test_smiles.csv") @pytest.fixture def model_path_classification(data_dir): retur...
ad1a0f1012b6d3801ea757f09dd7e7252b387357a4c39a5985a08ef3e8a6dc4f
Python
2,256
79
# 'grep' import regex from regex_syntax import * opt_show_where = 0 opt_show_filename = 0 opt_show_lineno = 1 def grep(pat, *files): return ggrep(RE_SYNTAX_GREP, pat, files) def egrep(pat, *files): return ggrep(RE_SYNTAX_EGREP, pat, files) def emgrep(pat, *files): return ggrep(RE_SYNTAX...
c540f7e0b7d7684910596a749c85c5395be45eca2c7943ed4346d6b948f745ad
Python
2,257
53
import os import unittest from tempfile import TemporaryDirectory from nnunetv2.utilities.file_path_utilities import copy_file_if_newer class TestCopyFileIfNewer(unittest.TestCase): def _write(self, path: str, content: str, mtime: float) -> None: with open(path, 'w') as f: f.write(content) ...
3e1cd315602c0221f303ea95a12b44527a2b5de181ce085ec66397c92ebc2ae5
Python
2,260
64
import pandas as pd import numpy as np import glob import random import numpy as np import json def softmax(x, T): return np.exp(x/T)/np.sum(np.exp(x/T), -1, keepdims=True) def parse_pssm(path): data = pd.read_csv(path, skiprows=2) floats_list_list = [] for i in range(data.values.shape[0]): ...
aec21edeb35166971d34e95e7f7841e14519b8216735e8656a642cf705280558
Python
2,261
71
################################################################################ # Code from # https://github.com/pytorch/vision/blob/master/torchvision/datasets/folder.py # Modified the original code so that it also loads images from the current # directory as well as the subdirectories ###############################...
417b2f49efbc2236b0fe610df9d344769f33db17b71ca47bcf2607577adb7af4
Python
2,267
49
#Comprehensive mapping of mutations to the SARS-CoV-2 receptor-binding domain that affect recognition by polyclonal human serum antibodies #https://www.biorxiv.org/content/10.1101/2020.12.31.425021v1.full.pdf #download https://github.com/saketkc/pysradb #!pip install -U pysradb #!pysradb metadata SAMN17185313 #https://...
d8dfbf3b07210fdb98316d88211347e34bd41a98e3e73565cc8550e9de7bc9fc
Python
2,268
75
#!/usr/bin/env python # # Copyright (c) 2020 10X Genomics, Inc. All rights reserved. # """A helper stage to determine whether or not to disable the legacy bam file (holding all reads).""" from __future__ import annotations from typing import TYPE_CHECKING import martian if TYPE_CHECKING: import cellranger.mro_t...
2a87fd626f373cda0701eac081b8e99aae8e4368e337ebdfff9c791bedde677a
Python
2,269
50
from matplotlib import pyplot as plt import numpy as np import os import sys import pickle from rCPGswCPG.utils.gen_utils import get_project_root, create_dir_if_not_exist W_Insp_Sw1 = 0.005 data_path = os.path.join(get_project_root(), "data", "experiments", f"KF_lesioning_different_amplitude_stim_{W_Insp_Sw1}", "runs"...
8e37bc8c94f02ec3aca034215e96b70dba538ff0214222c3fc0b84795b7aa2eb
Python
2,270
72
# Copyright 2020-2020 Biomedical Imaging Group Rotterdam, Departments of # Medical Informatics and Radiology, Erasmus MC, Rotterdam, The Netherlands # # 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 Licen...
fae0584222c9ba8cc5800fc1c224775daa6ae6edb2f96a8d8aeda630db201312
Python
2,270
67
import scanpy as sc import anndata import numpy as np import scipy.sparse as sp import pandas as pd import time import scanorama import matplotlib.pyplot as plt a_adata = sc.read_h5ad("PATH_TO_a_H5AD") b_adata = sc.read_h5ad("PATH_TO_b_H5AD") ortholog_table_path = "PATH_TO_ORTHOLOG_TABLE.csv" ortholog_table = pd.read...
a2481ba6aee9bee5d1baeb745b46f453feb794407562d7cb5758d7934de572ee
Python
2,273
89
import pandas as pd import numpy as np from sklearn.feature_selection import RFECV from sklearn.linear_model import LogisticRegression from sklearn.preprocessing import StandardScaler np.random.seed(42) # ----------------------------- # 1. Load data # ----------------------------- X = pd.read_csv("./data/data_0.csv",...
9548c7abd9a78c0bc4c2f73313f6541c969164a2abdd69f8e94238b6d05facd3
Python
2,278
60
# This code is part of OpenFE and is licensed under the MIT license. # For details, see https://github.com/OpenFreeEnergy/gufe import warnings from typing import ClassVar from gufe.storage.errors import ChangedExternalResourceError, MissingExternalResourceError class ResultServer: """Class to manage communicatio...
8fa506548adc49dd93c471d0da1a9cf5a2e64b54aed69267e6f54b59c4e59b3f
Python
2,279
50
from matplotlib import pyplot as plt import numpy as np import os import sys import pickle from rCPGswCPG.utils.gen_utils import get_project_root, create_dir_if_not_exist W_Insp_Sw1 = 0.0 data_path = os.path.join(get_project_root(), "data", "experiments", f"Intact_network_different_amplitude_stim_{W_Insp_Sw1}", "runs"...
8c787863b6cdf6397655d9222819b56e906537d761e78891974a35046555d31f
Python
2,282
72
from pathlib import Path import click import click_log import networkx as nx from ... import io from ..._cli.utils import catch_exception, logger from ..._steinbock import SteinbockException from ..._steinbock import logger as steinbock_logger from .. import graphs @click.command(name="graphs", help="Export neighbo...
fb58f5ba9a74af175aca94297fab99a100af7fe55e7c844082980de25ba1ba84
Python
2,282
80
import numpy as np import tifffile from PIL import Image from torch import nn import torch def save_as_tif(imgs, filename, normalize=False): """ Save numpy array as tif file Parameters ---------- imgs : np.array Data array filename : str Filepath to save result normalize :...
43e3165de23e3cd672eea0142d4837634a8cd9280a073ff236d6b7918c8db197
Python
2,283
43
if len(sys.argv)!=2: sys.exit("\n\nREQUIRED: pandas, pathlib; tested with Python 3.7.9 \n\nUSAGE: python proteinGroupsCombinePD.py <path to folder containing *Protein.txt file(s) like \"L:\promec\Animesh\Samah\mqpar.xml.1623227664.results\" >\n\nExample\n\npython proteinGroupsCombine.py L:\promec\Animesh\Samah\mqpar.xm...
1f39fd1011cff4762b74d929e64005deee8fb99e6c5351e5698633b534df8a73
Python
2,285
93
import torch def batch_stack(props): """ Stack a list of torch.tensors so they are padded to the size of the largest tensor along each axis. Parameters ---------- props : list of Pytorch Tensors Pytorch tensors to stack Returns ------- props : Pytorch tensor Stack...
7accd8b8484319342792c57161f6f13343fc8b3564d225023bbc0e9ba60406f9
Python
2,286
72
from typing import Optional, Union import numpy as np import pandas as pd import ggetrs as gg def run_gsea( genes: Union[list, np.ndarray], library: str = "BP", threshold: Optional[float] = 0.05, background: Optional[Union[list, np.ndarray]] = None, use_pvalue: bool = False, ) -> pd.DataFrame: ...
4d7c9b93dc95f86e1ff7528a87fb65d041bcb7557b982656831a54ed6dc2dacc
Python
2,289
81
"""Training loops, cross-validation, and metric computation.""" from nfml.train.engine import ( classifier_val_step, classifier_train_step, predict_batch, predictor_val_step, predictor_train_step, vae_loss, vae_val_step, vae_train_step, ) from nfml.train.kfold import evaluate_holdout, t...
28cef1ee23aae39ec9f4e16f5c0a3497270cc1e05a814a174cff74c9a0354781
Python
2,294
45
#python pepQuanProtMap.py "L:/promec/TIMSTOF/LARS/2026/260908_Moreforsk/combined/txtLen/peptides.txt" "A0A8C5CNW5" #python pepQuanProtMap.py "L:/promec/TIMSTOF/LARS/2026/260908_Moreforsk/trypsin/combined/txtLen/peptides.txt" "A0A8C5CNW5" import sys if len(sys.argv)!=3:sys.exit("USAGE: python pepQuanProtMap.py <tab-sep-...
595cdd9c0ab8306ba8f9e9fee5cbaccb0e411efece2cdb8d4083579597ea36ca
Python
2,295
65
from dataclasses import dataclass @dataclass(frozen=True) class WindowConfig: """Configuration for pre/post-stimulus analysis windows. Two modes: Train mode (symmetric=False): Standard analysis with pre-stim baseline, full stim train, and post-stim window. Used for 700ms, 2700ms. ...
647adeb3356e467c48b93092556783c25e7ef3b014103f43089145b3157da836
Python
2,296
71
"""Data filtering utilities for electrophysiology analyses. Standard filters for modulated, pulse-locked, and non-pulse-locked units. """ import numpy as np import pandas as pd def filter_modulated(df, max_z_score=50, min_spikes=50): """Filter to modulated units (both PL and NPL).""" for ch in df['stim_chann...
e738f39859693cd5f176c873a652c12a8ddecf21562ac80498dd49e2aa767f6b
Python
2,297
79
from __future__ import annotations import os import tempfile from pathlib import Path import bids.layout import pytest from hypothesis import database, settings from pyfakefs.fake_filesystem import FakeFilesystem import snakebids.paths.resources as specs from snakebids import resources, set_bids_spec ## Hypothesis ...
74e2e2f23cd7844bab47b60117e64977153ac2b3db3bcda6dc8ccd9172d7a3cd
Python
2,301
52
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri May 31 11:22:59 2024 @author: Ehsan.Sayyah """ import numpy as np from rdkit import Chem import os import argparse import glob import shutil import time import subprocess import os import glob import shutil import multiprocessing base_folder_path = '/...
191b7a2610e200a4ed6bc487615e76e0293997bc03d76fa8acd09537d15c6c80
Python
2,302
61
from pathlib import Path from steinbock import io class TestIO: def test_read_panel(self, imc_test_data_steinbock_path: Path): io.read_panel(imc_test_data_steinbock_path / "panel.csv") # TODO def test_write_panel(self, imc_test_data_steinbock_path: Path): pass # TODO def test_list_ima...
8bcb9201e633e180f272f9fe159ee69608bb653e5508d19eeecbc8bba4180e91
Python
2,303
69
from __future__ import division from ldscore.irwls import IRWLS import unittest import numpy as np import nose from numpy.testing import assert_array_equal, assert_array_almost_equal from nose.tools import assert_raises class Test_IRWLS_2D(unittest.TestCase): def setUp(self): self.x = np.vstack([np.ones(...
aa10cc5e2cbda926a59f319a55ae0a8ca5199d74a2e4b297ebaa0906255346b5
Python
2,307
84
import pandas as pd import numpy as np from sklearn.linear_model import LogisticRegressionCV from sklearn.preprocessing import StandardScaler # ----------------------------- # 1. Load data # ----------------------------- X = pd.read_csv("./data/data_0.csv", header=None) features = pd.read_csv("./data/features_0.csv", ...
3322fd1e36828a90536f32122e4e59edebd5bc58f61e79f29930891112c8c084
Python
2,313
63
#!/usr/bin/env python # # Copyright (c) 2022 10X Genomics, Inc. All rights reserved. # """Figures out if gDNA stages should be run.""" import martian import cellranger.csv_io as cr_csv_io __MRO__ = """ stage DISABLE_TARGETED_STAGES( in csv probe_set, in bool is_visium_hd, out bool disable_targeted_gd...
d3543929781ef95082c34bd83c91ec81d753f8fb51ba1f9502f4d13f0a7656f4
Python
2,315
69
"""Parser module to parse gear config.json.""" from typing import Tuple from flywheel_gear_toolkit import GearToolkitContext # from utils.curate_output import demo import sys import os from shared.utils.curate_output import demo import warnings import logging log = logging.getLogger(__name__) def parse_config( ...
12fc4f4ca43fb8c38edfbe87306925b049890ea16359f29b84c9887647964d9e
Python
2,316
70
"""Simplified EEG Signal Classification Execution Script""" import os from pathlib import Path import torch import torch.backends.cudnn as cudnn from eeg_visual_classification.utils.lib import ( create_parser, extract_model_options, get_dataloaders, get_model_hash, load_checkpoint ) from ..models import MODEL_REGI...
881e1c821edcef08d11dc76fba933a874a93dbe413ad4727c6b84cdadf11fbc2
Python
2,316
57
#!/usr/bin/env python # Copyright 2017-2026 Biomedical Imaging Group Rotterdam, Departments of # Medical Informatics and Radiology, Erasmus MC, Rotterdam, The Netherlands # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obt...
2ffb9796f8e2dcffdd9d8811fd7c24c9154356b0f81b64cfdff67d3fa33bf64c
Python
2,317
65
''' Created on 08.04.2019 Updated: 26.09.2020 @author: Niklas Pallast and Markus Aswendt process all DTI data ''' import glob import os import numpy as np def findData(path): regAtlas_list = [] fileALL = glob.iglob(path + '/GV*/DTI/DSI_studio/*StrokeMask.nii.gz', recursive=True) for filename in fileAL...
eacbe2ed8804f87d554217b25d6c5f01858abb6d844bb362e212b4b589f04be0
Python
2,320
74
import math import torch import torch.distributed as dist from detectron2.modeling.roi_heads import FastRCNNConvFCHead, MaskRCNNConvUpsampleHead from detectron2.utils import comm from fvcore.nn.distributed import differentiable_all_gather def concat_all_gather(input): bs_int = input.shape[0] size_list = comm...
57018d8baf6c64f481d11d2f1cafd82381798812778892cb01b79640a064246c
Python
2,321
68
import numpy as np import pandas as pd import pytest import xarray as xr from hsnn.analysis.png import stats @pytest.fixture def labels() -> pd.DataFrame: return pd.DataFrame({ "image_id": ["a", "b", "c", "d"], "left": [1, 1, 0, 0], "top": [1, 0, 1, 0], }) @pytest.fixture def occ_ar...
cdd3f43227da346fc9741cd1a2e779fdcf20a4c58bc5c8eca15bb5bba383d28e
Python
2,321
60
import argparse from pathlib import Path import joblib def baseline_predict(text, model_path): model = joblib.load(model_path) return str(model.predict([text])[0]) def bert_predict(text, checkpoint_path, pretrained_model=None): try: import torch from transformers import AutoTokenizer ...
9a102ab767cd702886e3359dab4b08320dde48962ec5f33ae542283c6eef9d07
Python
2,325
73
############################################################################ # Copyright (c) 2022-2026 University of Helsinki # Copyright (c) 2019-2022 Saint Petersburg State University # # All Rights Reserved # See file LICENSE for details. ############################################################################ ...
ed8ed3859c88bd5b8e4759e40c9a6c7496cc6858eed1fd7974b54b73b384d78f
Python
2,326
65
''' Created on 08.04.2019 Updated: 26.09.2020 @author: Niklas Pallast and Markus Aswendt process all DTI data ''' import glob import os import numpy as np def findData(path): regAtlas_list = [] fileALL = glob.iglob(path + '/GV*/DTI/DSI_studio/*mod_peri_scaled.nii.gz', recursive=True) for filename in f...
a1b90ef48bfa96b6a4cec8dd91c5bdac93c154f071777ce9fcce3c20ab59e8a3
Python
2,328
56
import torch import numpy as np import os import glob import tqdm import torch.nn as nn from protein_mpnn_utils import ProteinMPNN, tied_featurize, parse_PDB import subprocess as sb import sys def get_protein_mpnn(version='v_48_020.pt'): """Loading Pre-trained ProteinMPNN model for structure embeddings""" hid...
8677fd4d56f7efa4d1f6ce63cb9675ce082a2af03c4e45d5ab4dd37015475fe1
Python
2,331
92
from mesa.examples.advanced.epstein_civil_violence.agents import ( Citizen, CitizenState, Cop, ) from mesa.examples.advanced.epstein_civil_violence.model import EpsteinCivilViolence from mesa.visualization import ( Slider, SolaraViz, SpaceRenderer, make_plot_component, ) from mesa.visualizat...
ace333cdcd8a1b21d4c66e48241d11e4ed89b6736a3242b719e17275bc3d3770
Python
2,331
65
''' Created on 08.04.2019 Updated: 26.09.2020 @author: Niklas Pallast and Markus Aswendt process all DTI data ''' import glob import os import numpy as np def findData(path): regAtlas_list = [] fileALL = glob.iglob(path + '/GV*/DTI/DSI_studio/*_rsfMRISplit_scaled.nii.gz', recursive=True) for filename ...
0eb49cf7f3deda35004ef58415c2302d106b86fabc03ecdbfa2c578a2e904702
Python
2,334
110
""" Functions for surface creation. """ # Author: Oualid Benkarim <oualid.benkarim@mcgill.ca> # License: BSD 3 clause from vtk import (vtkPolyData, vtkCellArray, vtkTriangleFilter, vtkVertexGlyphFilter) from .mesh_elements import get_edges from ..vtk_interface.wrappers import BSPolyData from ..vtk_...
e9bfd856748e1fa1f2aaae39bc5b5ed02061ff3e7db5b1be2aa159debd3a24ef
Python
2,334
54
# Copyright (c) Facebook, Inc. and its affiliates. import torch from detectron2.layers import nonzero_tuple __all__ = ["subsample_labels"] def subsample_labels( labels: torch.Tensor, num_samples: int, positive_fraction: float, bg_label: int ): """ Return `num_samples` (or fewer, if not enough found) ...
74fdf85e7030af8c6cce417f93512f3cd14194790fb719da8dc5769ddb139bd8
Python
2,335
72
# Copyright (c) Facebook, Inc. and its affiliates. # pyre-unsafe from dataclasses import dataclass from typing import Union import torch @dataclass class DensePoseChartPredictorOutput: """ Predictor output that contains segmentation and inner coordinates predictions for predefined body parts: * coa...
bddcb38817e3b984158ca13ec9fb6ad0361de08516bdf02c91a9b135642ce458
Python
2,335
75
# # Copyright (c) 2024 10X Genomics, Inc. All rights reserved. # """A helper stage to disable stages in SC_MULTI_CORE.""" from __future__ import annotations import martian __MRO__ = """ stage DISABLE_MULTI_CORE_STAGES( in bool is_pd, in bool disable_gex, in bool disable_multi_count, in...
5162eca0cc678058168efdf0c58fadf55ad0b8976af3c34ecf248c49ac1b6cb5
Python
2,337
80
""" core/connectivity.py -------------------- Pearson correlation-based functional connectivity. """ import numpy as np import pandas as pd def compute_connectivity(rate_df: pd.DataFrame, zscore: bool = True): """ Compute the pairwise Pearson correlation matrix from per-channel firin...
6f43738892045307bd9c8a8c63f3f684c4b6521c84a50c17337b7775558285cf
Python
2,338
87
""" Converted from MATLAB script at http://billauer.co.il/peakdet.html Returns two arrays function [maxtab, mintab]=peakdet(v, delta, x) %PEAKDET Detect peaks in a vector % [MAXTAB, MINTAB] = PEAKDET(V, DELTA) finds the local % maxima and minima ("peaks") in the vector V. % MAXTAB and MINTAB cons...
21c58ffd8ba11fb1a031fcc4b670ad40abba78eaaff527a6e8cdc5ca2af37e02
Python
2,339
55
import matplotlib.pyplot as plt from mne.report import Report # topomap scale ch_types = ['mag', 'grad', 'eeg'] scale = {'mag': 1200, 'grad': 400, 'eeg': 40} chan_toplot = {'mag': ['MEG2111'], 'grad': ['MEG2112'], 'eeg': ['EEG070']} col_cond = {'trav': 'crimson', 'STANDING': 'dodgerblue', 'TRAV_OUT': 'crimson...
a38c86da87271b2aae739a423a90114a1c5ec764b440ff9d9319dc3f39240032
Python
2,350
83
import matplotlib.pyplot as plt import networkx as nx import solara from matplotlib.figure import Figure from mesa.examples.advanced.alliance_formation.model import ( AllianceScenario, MultiLevelAllianceModel, ) from mesa.visualization import SolaraViz from mesa.visualization.utils import update_counter model...
7c251df706b373cecb886ae338c7364804f170e8bfe38e42b7a08f739ae001a9
Python
2,351
112
# -*- coding: utf-8 -*- """For testing neuromaps.transforms functionality.""" import pytest from neuromaps import transforms @pytest.mark.xfail def test__regfusion_project(): """Test projecting a volume to a surface.""" assert False @pytest.mark.xfail def test__vol_to_surf(): """Test projecting a volu...
b6f0488a2f244227219049232877cc19dc3d8e2b44f32cef6a8cb1e44e7d1c6f
Python
2,351
70
from batchgenerators.utilities.file_and_folder_operations import * from nnunetv2.dataset_conversion.generate_dataset_json import generate_dataset_json from nnunetv2.paths import nnUNet_raw import SimpleITK as sitk if __name__ == '__main__': """ """ # extracted training.zip file is here base = '/home/...
ff187fe91d61dee211029ff6b1c8f151391775f4910ac21cf78dd4b01ea9b16f
Python
2,351
75
# # Copyright (c) 2024 10X Genomics, Inc. All rights reserved. # """Replace low UMI cells from cell_types.csv.""" import csv import martian import numpy as np import cellranger.matrix as cr_matrix from cellranger.cell_typing.broad_tenx.cas_postprocessing import ( LOW_UMI_BARCODE_KEY, MIN_CELL_TYPE_UMI, ) _...
58caa1333213a842b7fb8be31a8534b6514ae668968e794c7d7e1bb84913355f
Python
2,356
80
#!/usr/bin/env python # # Copyright (c) 2020 10X Genomics, Inc. All rights reserved. # """A helper stage to build CS outs tailored to the multiplexing strategy.""" from __future__ import annotations from typing import TYPE_CHECKING, Any import martian from cellranger.multi.build_per_sample_outs import build_sample_...
425ced6c8ce6333f83b201dc78b81a27b73ea59bf53522db524ef05246f3ee12
Python
2,357
67
#@UIService ui # BARlib.py # IJ BAR: https://github.com/tferr/Scripts # # Template BAR library (http://imagej.net/BAR#BAR_lib) to be placed in BAR/lib. This file # demonstrates how functions/methods in a common file can be shared across your scripts. # To load such scripting additions, append the following to your Jyt...
fabe780eaf565fc753bce77ab385b982a88508f9358d4a16b71bbd5af0f63475
Python
2,360
69
import sys import os sys.path.append(os.path.abspath( os.path.join(os.path.dirname(__file__), '../../'))) from src.hyperparameter_search.search_space.search_space import SearchSpace from src.hyperparameter_search.search_space.optuna_search_space import OptunaSearchSpace from src.hyperparameter_search.multitasking i...
57485e8afd169f0ea80e0f36d9430eb2c4a4f762d9b78c92dc1e1b10c28827e3
Python
2,363
58
# This script is part of navis (http://www.github.com/navis-org/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...
15faa3a9ce3639623381e1551f17fcd350b607048bc335ae94e4412ade48424a
Python
2,365
88
""" Created on 10/08/2017 @author: Niklas Pallast Neuroimaging & Neuroengineering Department of Neurology University Hospital Cologne """ import os, sys import changSNR as ch import brummerSNR as bm import sijbersSNR as sj import numpy as np import glob import nibabel as nii def snrCalclualtor(input_file, method...
f83032e393f718a46ba90c6a364994f92b8cd3a5bf9131459a0bb9cc28effae3
Python
2,374
60
from batchgenerators.utilities.file_and_folder_operations import * import shutil from nnunetv2.dataset_conversion.generate_dataset_json import generate_dataset_json if __name__ == '__main__': """ How to train our submission to the JHU benchmark 1. Execute this script here to convert the dataset into nnU-...
6e4716758f6990916081cbb65a5829b0648c09479e29ed257f1eaba245e41e5e
Python
2,375
76
"""Test if namespsaces importing work better.""" import pytest def test_import(): """This tests the new, simpler Mesa namespace. See https://github.com/mesa/mesa/pull/1294. """ import mesa # noqa: PLC0415 from mesa.datacollection import DataCollector # noqa: PLC0415 _ = DataCollector ...
da4125c0c292e0777ea158ac7e99b7c8156993d211c34527e4a0f8fbe96ab36b
Python
2,383
76
# %% from __future__ import annotations import json import os import os.path as op import pickle import sys from wasabi import msg from src.preprocessing import info_extraction as ie from src.preprocessing import prep_eeg as prep # helper pakagee sys.path.append(op.abspath('..')) # %% RAW_ROOT = '../../NOD-MEEG_up...
5d2fa44cd6c848c88d00f548db0cffce89dd21fcd7111f78dba83456243e628b
Python
2,385
62
# Copyright (c) Facebook, Inc. and its affiliates. import math from typing import List import torch from detectron2.solver.lr_scheduler import LRScheduler, _get_warmup_factor_at_iter # NOTE: PyTorch's LR scheduler interface uses names that assume the LR changes # only on epoch boundaries. We typically use iteration b...
d855405eba9a613896f3c4b86a81a6d5af02e5e89727ce771b69dd9d3ec79390
Python
2,385
53
# Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany # # 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://w...
4469367579feb974bd815da44f996594f75da83e83763ae7d805f978e9eaf6de
Python
2,386
90
"""This integration test is designed to ensure that the chemprop model can _overfit_ the training data. A small enough dataset should be memorizable by even a moderately sized model, so this test should generally pass.""" from lightning import pytorch as pl import pytest import torch from torch.utils.data import DataL...
bd18ddf8f2126fb7fee2638bec5a40f7b895727e3f92c4d380285fe55ee6e849
Python
2,387
70
import csv from lightning import pytorch as pl import numpy as np import pytest from chemprop.conf import LIGHTNING_26_COMPAT_ARGS from chemprop.data.dataloader import build_dataloader from chemprop.data.datapoints import MoleculeDatapoint from chemprop.data.datasets import MoleculeDataset from chemprop.featurizers.a...
252d5e3fb6057da21bcdf139a6eece0037382bebb8977506e3943f187ae73754
Python
2,388
108
# %% from __future__ import annotations import os import os.path as op import sys import joblib import matplotlib.cm as cm import matplotlib.pyplot as plt import mne import numpy as np import pandas as pd from matplotlib import font_manager as fm from matplotlib.gridspec import GridSpec from scipy.stats import ttest_...
af2c482007a94463dd9e7dc371e171d7ebd8919f4ae476f96d8bff04586aebd9
Python
2,392
74
import pytest from chemprop.utils import make_mol def test_no_keep_h(): mol = make_mol("[H]C", keep_h=False) assert mol.GetNumAtoms() == 1 def test_keep_h(): mol = make_mol("[H]C", keep_h=True) assert mol.GetNumAtoms() == 2 def test_add_h(): mol = make_mol("[H]C", add_h=True) assert mol.G...
0d2e37b5631d2629f4760e08efa2467808e1ccf79fb6529c9d0cf381300861d0
Python
2,395
67
import os import re from pathlib import Path # Directory where script module files are located SCRIPTS_DIR = Path('../micaflow/scripts') # Descriptions for each script descriptions = { "bet": "Brain extraction using HD-BET.", "synthseg": "Deep learning segmentation with SynthSeg.", "coregister": "Image co...
4673fe61397f2c3a766454441bf766d53db9d97ad8e7fcbf67821471af2698fe
Python
2,395
75
import numpy as np from DeepKnockoffs import KnockoffMachine from DeepKnockoffs import GaussianKnockoffs import data import parameters from sklearn import preprocessing for i in range(25): seed=i+1 print('No.',seed,'\n') X=np.loadtxt('../../Model-X/Dataset1/data/X_64_'+str(seed)+'.txt') X=preproc...
1edde89b5d94b0d4cd3848122686781d8453f2d75724ac4c8a5c5ab19c130ee9
Python
2,397
67
#!/usr/bin/env python # Copyright 2016-2019 Biomedical Imaging Group Rotterdam, Departments of # Medical Informatics and Radiology, Erasmus MC, Rotterdam, The Netherlands # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obt...
749e784724aa85b09624f1fe54aec1dfe3c3ab1890d17d423eaec28fac802cf5
Python
2,403
70
# -*- coding: utf-8 -*- """ Created on Tue Sep 5 15:54:11 2023 This script simulates traveling waves in V1, project the activity onto MEG and EEG sensors, and compare the predicted activity in sensors to empirical data. @author: laeti """ from toolbox.simulation import create_sim_from_entry from toolbox...
0a82a488dc6554493fa2b51e865e7e65ebfaecf96efbf263987db52bef8a83fd
Python
2,404
59
#!/usr/bin/env python # Copyright 2017-2020 Biomedical Imaging Group Rotterdam, Departments of # Medical Informatics and Radiology, Erasmus MC, Rotterdam, The Netherlands # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obt...
77745db4c9e86313cc9cd4840a68df685fdfb60ca7caf34ad109eb15bbd727e7
Python
2,404
67
from __future__ import annotations from pathlib import Path import sys PROJECT_ROOT = Path(__file__).resolve().parents[1] if str(PROJECT_ROOT) not in sys.path: sys.path.insert(0, str(PROJECT_ROOT)) from rdkit import Chem from src.protonation.openbabel_adapter import OpenBabelError, OpenBabelProtonator from src....
51ad69f2b3b2a8baddaf4c7380f0f9a9ccb34323130319e6692b8509afbf80a7
Python
2,405
64
import argparse import pandas as pd from sklearn.model_selection import KFold import config def main(): parser = argparse.ArgumentParser() parser.add_argument('-d', '--dataset', type=str, required=True, help='dataset file path') parser.add_argument('-f', '--fold', type=int, default=10, help='number of fold...
41209b45ce2ec0576e172029c5a43287af31475d40efe4b8cb149e0cb77b0089
Python
2,406
61
import shutil from pathlib import Path from nnunetv2.dataset_conversion.Dataset027_ACDC import make_out_dirs from nnunetv2.dataset_conversion.generate_dataset_json import generate_dataset_json def copy_files(src_data_dir: Path, src_test_dir: Path, train_dir: Path, labels_dir: Path, test_dir: Path): """Copy files...
bb34fc440e4a3143e512ae061161fe3c780aa190beed8c46fb1c1d2b1fbfc352
Python
2,406
55
from batchgenerators.utilities.file_and_folder_operations import * import shutil from nnunetv2.dataset_conversion.generate_dataset_json import generate_dataset_json from nnunetv2.paths import nnUNet_raw if __name__ == '__main__': """ Download the dataset from huggingface: https://huggingface.co/datasets/Ab...
d315ba44ed4180c3d76bf9511c4c367b74b681d5d881e0e7338a74e72ad659fe
Python
2,406
67
"""Move carbon-centred anions onto adjacent heteroatoms after (de)protonation. MolGpKa (and rule-based backends) can deprotonate an acidic C-H directly, giving a carbanion, for example the enol(ate)-forming central C-H of a 1,3-diketone, which is returned as ``CC(=O)[CH-]C(C)=O``. The chemically dominant form is the e...
09817e2ea5acada9fdc61dadcc753cd6a1fb100f76cb10bcc0bd8e40b69819ac
Python
2,412
65
import os.path import torchvision.transforms as transforms from data.dataset.base_dataset import BaseDataset from data.image_folder import make_dataset from PIL import Image import numpy as np import torch # from IPython import embed class TwoAFCDataset(BaseDataset): def initialize(self, dataroots, load_size=64): ...
c912b824d2d08c09bfa7bf14ed7027565cbd76fc8def8a1b68148ad4464c5f8c
Python
2,415
73
import time import altair as alt import numpy as np import pandas as pd import streamlit as st from mesa.examples.basic.conways_game_of_life.model import ConwaysGameOfLife model = st.title("Conway's Game of Life") num_ticks = st.slider("Select number of Steps", min_value=1, max_value=100, value=50) height = st.slide...
08f7fd58f56bfb232860b1bbf560c7f40884a25cf4f95df990179ed55d9dbcc2
Python
2,417
89
from pathlib import Path import click import click_log from ... import io from ..._cli.utils import catch_exception, logger from ..._steinbock import SteinbockException from ..._steinbock import logger as steinbock_logger from ..neighbors import NeighborhoodType, try_measure_neighbors_from_disk _neighborhood_types =...
d1628ec602c6b4c72f5062f3f3e34b280c93a00357a4483b5d19694f3fddc0d7
Python
2,419
74
# %% from __future__ import annotations import json import os import os.path as op import pickle import sys from wasabi import msg from src.preprocessing import info_extraction as ie from src.preprocessing import prep_meg as prep # helper pakage sys.path.append(op.abspath('..')) # %% RAW_ROOT = '../../NOD-MEEG_upl...
74156866b0cb6ad6551b03641541ed4b3631dbd5b2859b80ec911d423275dc5c
Python
2,420
80
""" Wrappers for VTK lookup tables. """ # Author: Oualid Benkarim <oualid.benkarim@mcgill.ca> # License: BSD 3 clause import vtk from vtk.util.vtkConstants import VTK_STRING, VTK_UNSIGNED_CHAR from vtk.util.numpy_support import numpy_to_vtk from .base import BSVTKObjectWrapper from ..decorators import unwrap_input ...
886b79058e166e7f49903f19deee0ff8f7eaacbbbf354ce12ed8ef10399f6639
Python
2,420
60
from collections.abc import Iterable import numpy as np import torch def recursive_fix_for_json_export(my_dict: dict): # json is ... a very nice thing to have # 'cannot serialize object of type bool_/int64/float64'. Apart from that of course... keys = list(my_dict.keys()) # cannot iterate over keys() if...
41ef9044af2244265e328aca2c222af87b870629783c05c0873dca31faaae478
Python
2,425
67
import torch def calc_mean_std(feat, eps=1e-5): # eps is a small value added to the variance to avoid divide-by-zero. size = feat.data.size() assert (len(size) == 4) N, C = size[:2] feat_var = feat.view(N, C, -1).var(dim=2) + eps feat_std = feat_var.sqrt().view(N, C, 1, 1) feat_mean = feat...
e35c7f8f95c42891397dedefbcca042fa8a1227bc4124a6980d483a32b34d70b
Python
2,426
93
import pandas as pd import numpy as np from sklearn.ensemble import RandomForestClassifier import shap np.random.seed(42) # ----------------------------- # 1. Load data # ----------------------------- X = pd.read_csv("./data/data_0.csv", header=None) features = pd.read_csv("./data/features_0.csv", header=None)[0].val...
cfe3996ce41e78ae7ce4f78bff629268c5f0b33b0e2379543382d1c3b65c2f57
Python
2,427
62
import tobii_research as tr import time import numpy as np found_eyetrackers = tr.find_all_eyetrackers() my_eyetracker = found_eyetrackers[0] print("Address: " + my_eyetracker.address) print("Model: " + my_eyetracker.model) print("Name (It's OK if this is empty): " + my_eyetracker.device_name) print("Serial number: "...
3f96932ded49e62df7fedc07e48f19cd70c50e2627516a4a4f67817592f05940
Python
2,428
90
from __future__ import annotations import re import subprocess as sp import sys from pathlib import Path import jinja2.parser from jinja2 import nodes from jinja2.ext import Extension from typing_extensions import override class GitConfigExtension(Extension): """Retrieve settings from git configuration. Sh...
493b6c3a1e493554cd2db12d41b9fe5887c0f3d719dddd98d54a97089252f655
Python
2,430
74
#!/usr/bin/env python # # Copyright (c) 2022 10X Genomics, Inc. All rights reserved. # """Gets the sufficient statistics from rust stage and generate plotly plot.""" import json import numpy as np import tenkit.safe_json as tk_safe_json from cellranger.targeted.targeted_constants import GDNA_PLOT_NAME from cellran...
a850981b0d3cc3fe33271db04d8bbf9859342f70bf07a86d15f099f68b3d1380
Python
2,430
61
#!/usr/bin/env python3 # ############################################################################ # Copyright (c) 2022-2026 University of Helsinki # Copyright (c) 2020-2022 Saint Petersburg State University # # All Rights Reserved # See file LICENSE for details. #####################################################...
090558187035ac51a20e054e3ec8eb9028a1293c7d9f546685e2b5806cdbd6f3
Python
2,440
67
#!/bin/python """ Script for registering and processing microglia ASAP snRNA-seq samples for Putamen (PUT). Workflow steps and notes are identical to PFC script. """ import truster import pandas as pd import os # Paths to references and configs cellranger_index = "/scale/gr01/shared/common/genome/10Xindexes/cellrang...
59a094b05f0a21587f7e676863659f2285584d718e7b45b3e52986ca3f6eaa66
Python
2,446
88
"""EEG datasets with class for dataset dataloader """ import torch # Dataset class class EEGDataset: """EEG dataset Returns: EEG dataset: some data source """ # Constructor def __init__(self, opt): # Load EEG signals loaded = torch.load(opt["eeg_dataset"]) # signals_pat...
80d4b07eb904475cb72dd83fc7044ae6899c3e2a6c8dc59a3413819e59974361
Python
2,448
71
"""The MFA timeout must actually stop a run that overruns. An alignment was observed hanging for ~55 minutes with a 30-minute timeout in force. The cause is a standard subprocess trap: MFA starts workers, and when the parent is killed those workers keep the stdout/stderr pipes open, so the cleanup read blocks forever....
0596f53162a6c9689bd14744be2ef8ec945611c35a32a34be27b4efa31c0f2d2
Python
2,449
106
# compate the distribution of the semantic labels in the training set and the test set import torch import argparse import numpy as np parser = argparse.ArgumentParser(description="Template") parser.add_argument( "-id", "--input-dataset", help="input EEG dataset path", ) parser.add_argument( "-sp1", ...
238f0f4f92df7e15f8f261c55acf367cc085fa083c01ce71a278d25f0b67d8ea
Python
2,454
77
#!/usr/bin/env python """ Functionality to preprocess a directory of images: Try reading them, crop etc. to desired size, ... And if corrupt (error), move them to different directory. This serves to speed up training by doing preprocessing beforehand. """ import os import shutil from PIL import Image from adain im...
c5801d91aadb66a8e7214514b662d51a386f6ec7477ab0b7af7301b66cb9a06a
Python
2,454
68
from pkg_resources import resource_filename from pangolin.model import * # Change this to the desired models. The model that each number corresponds to is listed below. model_nums = [0] # 0 = Heart, P(splice) # 1 = Heart, usage # 2 = Liver, P(splice) # 3 = Liver, usage # 4 = Brain, P(splice) # 5 = Brain, usage # 6 = T...
ec36123abd64f1fde58afc3ba7ffaa865a7e9c8bdf2f898a5433d5e0b446f9fd
Python
2,454
67
import torch from typing import Optional try: from emle.models import ANI2xEMLE, MACEEMLE from emle._units import ( _NANOMETER_TO_ANGSTROM, _HARTREE_TO_KJ_MOL, ) except ImportError: ANI2xEMLE = None MACEEMLE = None _NANOMETER_TO_ANGSTROM = None _HARTREE_TO_KJ_MOL = None cla...
63443f7e76981ee4eed59649ab8b6cef09bddd63da8d9ccace5d836afb82532f
Python
2,455
45
from typing import Tuple, Union, List from batchgenerators.transforms.abstract_transforms import AbstractTransform class Convert3DTo2DTransform(AbstractTransform): def __init__(self, apply_to_keys: Union[List[str], Tuple[str]] = ('data', 'seg')): """ Transforms a 5D array (b, c, x, y, z) to a 4D ...
0bdfd6a05e85d994209c4e41f5e05d5c3eb3d269dce8554a7df9bbfa858d0efc
Python
2,457
88
import pandas as pd import numpy as np from sklearn.linear_model import LogisticRegressionCV from sklearn.preprocessing import StandardScaler np.random.seed(42) # ----------------------------- # 1. Load data # ----------------------------- X = pd.read_csv("./data/data_0.csv", header=None) features = pd.read_csv("./dat...
ac20d925eca2659440db64790ecb3939552f625774bb50dc7c1115b92f728b74
Python
2,458
70
# # Copyright (c) 2022 10X Genomics, Inc. All rights reserved. # """A file to read and ingest cell_barcodes.json files produced by PARSE_MULTI_CONFIG.""" from __future__ import annotations import json from cellranger.barcodes.utils import load_barcode_whitelist from cellranger.chemistry import get_whitelist_name_fro...
95e6776bf5fd03d7da20ca240c73e4bc570702c23981757e9c27f450b36c05c8
Python
2,459
81
""" Put module information here """ __author__ = "Fabi Bongratz" __email__ = "fabi.bongratz@gmail.com" import numpy as np def read_obj(filepath): """ Read an .obj file in a way that separate mesh objects/structures are not merged """ vertices = [] faces = [] normals = [] vertices_struct...