sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
ec60b2ed10a1121a7ca121b9512809f0b0372b3a0bc88f3c4a2e31131b08c927
Python
3,409
83
from pytorch_lightning import Trainer, LightningModule, Callback from torch.nn.modules.dropout import _DropoutNd from typing import Any __all__ = ['StepDropout'] class StepDropout(Callback): def __init__( self, step_size, base_drop_rate, gamma=0., updat...
01491447cc49660b9b594c19690bfe090b014646120c6ff2568adc3b1fd003bf
Python
3,410
112
#!/usr/bin/env python import os import subprocess import plotting.configure_seaborn as cs import matplotlib.pyplot as plt import numpy as np import pandas as pd import seaborn as sns sns.set(context='paper', style='ticks', rc=cs.rc_params) plots_directory = os.path.join(os.path.sep, "calc", os.getenv("USER"), ...
071b7406622d157eafd40521bd786f685bf24f466d639d4d3588b19f0b99b658
Python
3,410
129
import argparse import os from collections.abc import Iterator from datasets import load_dataset from eir.setup.input_setup_modules.setup_sequence import ( _get_bpe_tokenizer_object, ) from eir.utils.logging import get_logger logger = get_logger(name=__name__) def create_dataset_text_iterator( dataset_name...
597a0bd78deab817c9948f172071e296dce85170f9e42cffb1cdfae270b89d4c
Python
3,410
92
"""Load GROQ models using LangChain.""" import os from getpass import getpass from langchain_groq import ChatGroq from chemgraph.utils.logging_config import setup_logger logger = setup_logger(__name__) def load_groq_model( model_name: str, temperature: float, api_key: str = None, prompt: str = None,...
a7979930787fc652ce4fe6be8b13173798fc7fc81db18b4bb407ec9dd9939df7
Python
3,410
105
############################################################################# ### Recursively moves through directories and extracts parameters and the ### ### mean protein amount across core and non-core neurons ### ############################################################################# ### Cop...
f9f1c738bba32c51597516e9f492507449ae0ed10a2807825a6e1627dcface30
Python
3,410
117
import os from types import SimpleNamespace from unittest.mock import Mock os.environ.setdefault("QT_QPA_PLATFORM", "offscreen") import matplotlib import numpy as np import pytest from PySide6.QtWidgets import QApplication from musclex.ui.widgets.image_viewer_widget import ImageViewerWidget # QuadrantFoldingGUI sel...
104497f4ece9e5703a4292918a6d2321fc0c03428d6e8fc0ab85155abb9f0a36
Python
3,411
103
import sys import os import time import numpy as np import pandas as pd import matplotlib.pyplot as plt import torch import torch.nn as nn import torch.optim as optim from torch.nn import functional as F import random from sklearn import metrics from collections import Counter from captum.attr import (IntegratedGradien...
50d8029dfcc2c277262fa7b397ea620d48abe4addc49b0bf158bfeba22e2db45
Python
3,411
80
import segmentation_models_pytorch as smp from torch import nn from collections import OrderedDict from typing import List, Callable from pytorch_lightning.core.mixins import HyperparametersMixin __all__ = ['SmpEncoder'] class ExternBase(nn.Module): def __init__(self, model_name: str): super().__init__()...
cf202c6e3c1b040a63bc91c694fc58990ee165d681abc2e977f6090a4805a235
Python
3,412
77
# Copyright 2021 HIP Applied Computer Vision Lab, 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...
25b2e2bbfa8616db2049d46406d8c0821211500060bc00c8ebdcdb76c603bb9e
Python
3,413
112
from pathlib import Path import pandas as pd from tqdm import tqdm from transformers import RobertaTokenizer, RobertaModel import torch import numpy as np import os from torch_geometric.data import Data, HeteroData import ijson def get_data_dir(server_id): if server_id == "206": return Path("/new_temp/fsb...
8119dffc9802caa01c7083e41bace05cec8f19bd29866e8e6c17f4236bfa68d0
Python
3,413
98
import numpy as np import torch from ModelCodes.autoencoderModelv2 import * from ModelCodes.classificationModelv1 import * import pickle import os import tqdm from sklearn.metrics import roc_curve, auc import argparse def parse_arguments(): parser = argparse.ArgumentParser(description="Autoencoder Training Script"...
a505f015066fc56466dd70dcbf83fe535d32811e7b799f1f6c9ef6566848b5c6
Python
3,413
80
# Need to install sprod first # Need to do module purge so that the R.cpp will work # Need R/4.0.2 import pandas as pd import os import platform os_type = platform.system() sprod_path = os.path.abspath(__file__) denoise_jb = sprod_path.replace('test_examples.py', 'sprod.py') input_path = sprod_path.replace('test_exam...
dc79a58b48df81ebb59b014cd370213eb1b6eb380a562b8ba0fb0cb91898baef
Python
3,413
93
import argparse import pandas as pd import numpy as np from pysnptools.snpreader import Bed, Pheno, SnpData from fastlmm.association import heritability_spatial_correction from sklearn.decomposition import PCA from sklearn.preprocessing import StandardScaler import os def run_pca(snp_prefix, out_file, n_components=2):...
3a8b1688e83a9d12f3f7c2fd27ff545a55f2891b4f582258d128ff10603dd490
Python
3,415
114
import torch.nn from torch.nn.parameter import Parameter import torch.nn.functional as F import torch.autograd as autograd import flair.nn import torch import numpy as np import pdb import copy import time import sys class EmbedController(flair.nn.Model): def __init__( self, num_actions, model_structure = N...
4085dec30269988f01eb76c677e41efe6b2a36b589cb7cb25c94705b394eb295
Python
3,415
117
#!/usr/bin/env python # author: Jannes Spangenberg # e-mail: jannes.spangenberg@uni-jena.de # github: https://github.com/JannesSP # website: https://jannessp.github.io from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, Namespace import os def parse() -> Namespace: parser = ArgumentParser( ...
40cd6cf1e63e8de49d41948cdfe221183fd86b18f2d99d681d5913c8ce045192
Python
3,415
91
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved import logging import numpy as np import torch from .masks_ops import mask_iou try: from torch_generic_nms import generic_nms as generic_nms_cuda GENERIC_NMS_AVAILABLE = True except ImportError: logging.debug( "Falling ba...
a3a591f8f6f5f945e351b240ff03d205e48ac788c73ec547fcc8bf0c537c0249
Python
3,416
83
import sys from torch.utils.data import DataLoader from geoseg.models.MixerUnet import reparameterize_model from geoseg.losses import * from geoseg.datasets.isic2018_dataset import ISIC_Dataset from geoseg.models.MixerUnet import ConvMixer_UNET_down from geoseg.models.MixerUnetcopy import Rep_UNET_down #from catalyst.c...
0d69df8d3ea43b783e780908f91e451fb1f253831981ebf61e0f9b23a092c9f6
Python
3,417
101
import torch from model import GNN_classifier from preprocess import generate_hetero_graph_loader, generate_homo_graph_loader_only_user from tqdm import tqdm import numpy as np import sys sys.path.append("..") from utils.eval import evaluate_on_all_metrics import argparse class homo_Trainer: def __init__( ...
cdfae7cfdf299cb5e25a4f1a2b9dcb61fb9038559d00e48c6bf621b48780a148
Python
3,417
86
import sys import json import os import pandas as pd import anndata import time import numpy as np from scipy import stats download_base = os.environ.get("SHMDIR", "/gpfs/bbp.cscs.ch/data/project/proj84/csaba/aibs_10x_mouse_wholebrain/") write = "/gpfs/bbp.cscs.ch/data/project/proj84/csaba/aibs_10x_mouse_wholebrain/"...
1e7f54390f15705a4632a3c644e6ecc3bb4c5945730583f6a35102e9c52d31df
Python
3,418
128
""" EEG Preprocessing Pipeline for Cognitive Workload Estimation This script implements the EEG preprocessing steps used in the study: "Estimating Cognitive Workload in Robot-Assisted Surgery Using Time and Frequency Features from EEG Epochs with Random Forest Regression". Preprocessing steps: 1. Common Average Refe...
2305105d2e271d45ab7ef87d7712539dce3c57dbcebaba6a0460835a6ed38c00
Python
3,418
131
# Copyright (C) CVAT.ai Corporation # # SPDX-License-Identifier: MIT import io import subprocess from collections.abc import Generator from fractions import Fraction from io import BytesIO from pathlib import Path import av import av.video.reformatter import librosa import numpy as np from PIL import Image from shar...
99356a8384b0656ba0bd2b448aed06132bfa1022a9142b900eedd1ec9a5fa677
Python
3,418
82
import numpy as np import pandas as pd from collections import defaultdict from tqdm import tqdm from pingouin import partial_corr df = pd.read_csv('features_spindles.csv.zip') df2 = pd.read_excel('ASD-TD(egi-data).xlsx', sheet_name='ASD') df2 = df2.rename(columns={'病案号':'SID', '性别':'Sex', '年龄':'Age', '精细\n动作':'精细动作...
a88976d6db4e4bf189c20942aff4ea1acae058788005db72102d33dc0fd7a823
Python
3,419
116
_base_ = [ '../_base_/datasets/coco_detection.py', '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py' ] # model settings model = dict( type='FCOS', backbone=dict( type='RepLKNet', large_kernel_sizes=[31,29,27,13], layers=[2,2,18,2], channels=[128,256,512...
facdff7f56d70df9d7666481436deff877f72638df43a3dbb665195fe21c47e6
Python
3,419
88
import numpy as np from dipy.utils.optpkg import optional_package from scilpy.ml.utils import IMPORT_ERROR_MSG torch, have_torch, _ = optional_package('torch', trip_msg=IMPORT_ERROR_MSG) # From https://github.com/tatp22/multidim-positional-encoding def get_emb(sin_inp): """ Gets a base embedding for one di...
9fab133fdae3531616e4b1cf5780bcc4d295e4026c2962b90f8b5d017a5cb3b6
Python
3,421
104
import threading import time import os import warnings from typing import Any import pytorch_lightning as pl __all__ = ['KeepAlive'] def terminate_program(log_fn=None): from ..mpi.mpi import has_mpi, MPI import signal log_fn = log_fn or print if 'SLURM_JOB_ID' in os.environ: try: ...
d2da8c2a8952922b5d731b9e8c587452965fcdda1e945b1fe2aaca2a15b0c6e1
Python
3,421
83
import numpy as np from monai import transforms class ZScoreNormalisation(object): ''' Calculate the z-score normalisation of the input image in a batch, i.e. (x-mean)/std. ''' def __init__(self): self.eps = 1e-8 def __call__(self, sample): mean = sample.mean() st...
1fb582b640433fdfbbcd1c7dc8ab8de7746e9eefbd526f8321e0c36f8633cf28
Python
3,422
99
# /------------------------------------------------------------------------------+ # | 19-JUL-2022 | # | Copyright (c) Bone Imaging Laboratory | # | All rights reserved ...
cb9a0108d51edd48b68a2c8663aae7cc61084f4d774dc678ecc2eabbfd749a03
Python
3,422
115
import numpy as np def rectangle( timestep: float, amplitude: float, start_gap: float, pulse_width: float, interpulse_gap: float, frequency: float, biphasic: bool = False, ): """Rectangular pulse.""" if timestep > 1.0 / (10.0 * frequency): raise ValueError( "The...
7f6eb06152ec8e14ac8af5cce2e3d919fa1d8c971d333e959dc0df1392297298
Python
3,423
110
''' O2H3 ''' import numpy as np import sys def intro(): print(""" SHORT List of potential energy surfaces for O2H3: P: potential energy, G: Gradient, D: Nonadiabatic coupling vector This is listed at the end of description to show the availability. For example: P/G means both potential energy and...
85a23fbecbc404c85e7b9d9f541a19f43ec2caf868204be9e51a46f34a1b253d
Python
3,424
88
#New: from __future__ import print_function, absolute_import import os.path as osp import glob import re from ..utils.data import BaseImageDataset class Brain(BaseImageDataset): """ Market1501 Reference: Zheng et al. Scalable Person Re-identification: A Benchmark. ICCV 2015. URL: http://www.liang...
21bb8623ce079d7fa4ffa9522c8e25985be2ffb3a2a40fcf9dc19af24026e4bd
Python
3,425
69
import numpy as np from sklearn.metrics.pairwise import euclidean_distances from .nbfr import generate_grid, radial_basis_function class Neuron: ''' Neuron class; multiple neuron objects within an FOV comprise an experiment. Each neuron possesses several parameters (n_modes, mode_centers, mode_widths, etc) that tog...
2cfe09a8ea7723fca671fba5df464b27a6d6d2cfdf1b2337478e0a84bdca112a
Python
3,425
91
# Copyright (C) CVAT.ai Corporation # # SPDX-License-Identifier: MIT """Aggregate what was annotated across a project: object counts per label and per object type for every task, printed and written to a CSV report. Steps: 1. Retrieve the project and its label names. 2. Walk the project's tasks and read each task...
6fa830eaac6ae53ac34af9db553f810f1f148a3e2c25d27b5a21e7a15408cb1d
Python
3,425
98
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ This script extracts streamlines depending on their U-shapeness. This script is a replica of Trackvis method. When ufactor is close to: * 0 it defines straight streamlines * 1 it defines U-fibers * -1 it defines S-fibers """ import argparse import json import loggi...
954c4f410a380e7f3a64a734726ddaed8ffb386c5ad65ebe70181df7efa9fe97
Python
3,425
98
import os.path as op import dipy.core.gradients as dpg import dipy.data as dpd import nibabel as nib import nibabel.tmpdirs as nbtmp import numpy as np import numpy.testing as npt from dipy.core.geometry import vector_norm from dipy.io.gradients import read_bvals_bvecs import AFQ.utils.models as ut from AFQ._fixes im...
af4714043e65c04407251bb1127e64754fab7bdc68819740eae373297e71b833
Python
3,425
63
import numpy as np from pytest import approx from brainscore_core.supported_data_standards.brainio.assemblies import NeuroidAssembly, DataAssembly from brainscore_vision import load_metric from .metric import RDM class TestCharacterization: def test_alignment(self): assembly = NeuroidAssembly([[1, 2], [1...
c86e2817dcb047a9ffd44aa2a28ca1be7624233e5ef5daf053c992f075296f10
Python
3,425
100
import torch from torch import nn from torch.nn import functional as F from torch.nn import init from .pooling import build_pooling_layer class ViT(nn.Module): def __init__(self, depth=0, pretrained=True, cut_at_pooling=False, num_features=0, new_in_channels=7, norm=False, dropout=0, num_classes...
f933c5a96dfd037bf7d2b8ab1008c5092cd87b2d84d05bef2546269c180718e7
Python
3,425
108
"""Utilities for preprocessing images with antspynet skullstripping.""" import ants import antspynet import numpy as np def rescale_intensity( image: ants.ANTsImage, dst_min: float = 0.0, dst_max: float = 255.0, f_low: float = 0.0, f_high: float = 0.999, ) -> ants.ANTsImage: """Rescales voxel...
95d0dfe55d2b0e2d4017e20c6af7b07f74398900c4b51dda264a3e57be22e3c3
Python
3,428
180
r""" Set the color palette for plotting. Reference --------- https://github.com/scverse/scanpy/blob/master/scanpy/plotting/palettes.py """ from matplotlib import cm, colors # Colorblindness adjusted vega_10 # See https://github.com/scverse/scanpy/issues/387 vega_10 = list(map(colors.to_hex, cm.tab10.colors)) vega_10...
b45161e15bc6ffb6fd1d4ae8c2a8d0c0b36fc89b8930b73abed5d80e60683068
Python
3,428
111
import brainpy as bp import brainpy.math as bm import numpy as np import jax import seaborn as sns import matplotlib.pyplot as plt from cann import CANN1D import scipy from scipy.stats import ttest_ind #set default ramndom seed for reproducibility np.random.seed(0) #set backend to cpu bm.set_platform('cpu') cann = CAN...
e707982c9fb214ee6eb3e21b34b87cafc59661162635683a350ca16c1c15bf83
Python
3,428
72
# -*- coding: utf-8 -*- """This sub-package provides routines for volumetric image processing in parallel This part of the *ClearMap* toolbox is designed in a modular way to allow for fast and flexible extension and addition of specific image processing algorithms. The toolbox part consists of two parts: * `Vol...
47db99bcc2e4bde42652729833b5f8b2a7a26afd1b6695ee188ade6261cd8b45
Python
3,429
99
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from dataclasses import dataclass import math from omegaconf import II import torch from fairseq import modules, utils from fairseq.logging i...
1ec323f8ec6a785b7c880da92bd97d6b61d04a925d74af0410a9cfb705385cd2
Python
3,430
83
import sys from torch.utils.data import DataLoader from geoseg.datasets.segpc import SegPCDataset from geoseg.models.MixerUnet import reparameterize_model from geoseg.losses import * from geoseg.datasets.isic2018_dataset import ISIC_Dataset #from geoseg.models.MixerUnet import ConvMixer_UNET_down from geoseg.models.Mix...
3bd6771a9cbee9e20f7fd4b2255dd937fea21b684959da4dd81e00fd0f761de2
Python
3,431
80
import unittest import numpy as np from numpy.testing import assert_array_almost_equal import os, sys sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../../"))) from heig.wgs.pvalue import saddle, _handle_invalid_pvalues, liu, liu_mod, saddle2 class Test_saddle(unittest.TestCase): def te...
71374483d9b93c6b569addf5ee64f8837debfe54afb7c1832bee939de8e5f977
Python
3,431
106
############################################################################# ### Recursively moves through directories and extracts parameters and the ### ### mean protein amount across core and non-core neurons ### ############################################################################# ### Cop...
129b86189ddacdc611fc65aaa63c138f2cbc616108097908d8a5bb6b3304db7f
Python
3,432
132
import torch.optim as optim from attentive import AttentiveMod from gat import GATMod from gin import GINMod from mpnn import MPNNMod def configure_optimizer(trial, model): optimizer_name = trial.suggest_categorical( 'optimizer', [ 'Adam', 'AdamW', 'RAdam']) weight_decay...
4388a2e990311d4204e8c39c314e16ec240bb2ae11fa96128a9b49aa36c6b45a
Python
3,432
101
# -*- coding: utf-8 -*- # python standard library inputs import os # external inputs import numpy as np import nibabel as nb from nipype.interfaces.ants import N4BiasFieldCorrection from scipy.signal import argrelextrema from scipy.ndimage.morphology import binary_fill_holes def skullstrip_flash(file_in, path_outpu...
76aca8e4888b5d015d61eb97a75634fa466ea9066db1ea778168f2966273d7a0
Python
3,432
77
import unittest import os import sys directory_path = os.path.abspath(os.path.join('../src/')) if directory_path not in sys.path: sys.path.append(directory_path) from utils import get_contig_lengths_dict from read_process import incorporate_replaced_pos_info,incorporate_insertions_and_deletions,\ get_positions_fr...
73f75f9e569ffda47bb6edf2b07dff9c11835d818390fbe0f4215577296e9572
Python
3,433
101
from functools import cached_property from typing import ClassVar from argclz import argument from neuralib.scanbox.core import SBXInfo from neuralib.suite2p import Suite2PResult from neuralib.util.utils import uglob from neuralib.util.verbose import fprint from .cli_core import CommonOptions __all__ = ['SBXOptions']...
faca137b8b36f585c479d7a399f05e6a4c3bd597ef7bcd847ea07c2a661470b6
Python
3,433
95
############################################################################# # Copyright (C) 2020-2026 MEmilio # # Authors: # # Contact: Martin J. Kuehn <Martin.Kuehn@DLR.de> # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may...
53233c748848200ba3226c4eccd11b1a346e3c549d1fb2997c368bb42b906d5c
Python
3,434
102
# Copyright (C) CVAT.ai Corporation # # SPDX-License-Identifier: MIT import argparse import math import time import traceback from collections.abc import Callable, Iterable from django.core.management.base import BaseCommand, CommandError from ..models import Task def parse_task_ids(value: str) -> list[int]: t...
1bdfb654a93954b1d4dda5bd55bbc710ff10418322d7e430e3c35081a8130570
Python
3,435
94
import torch import torch.nn as nn import torch.nn.functional as F import skimage.io as skio import numpy as np import config def get_dice(pred, organ_target): ''' Tversky loss :param pred: (B, C, 32, 256, 256) :param organ_target: (B, C, 32, 256, 256) ''' # the organ_target should be one-hot c...
b58934970b9f051e9aa2baceb03b937e0b7a2a9298e2b0439ceab88e036c00e1
Python
3,436
124
import torch import albumentations as A from albumentations.pytorch import ToTensorV2 from tqdm import tqdm import torch.nn as nn import torch.optim as optim from model import UNET from utils import ( load_checkpoint, save_checkpoint, get_loaders, check_accuracy, save_predictions_as_imgs...
4c122eb6e11c2f0cbdebba8e789b287218795a8ea5e92c6ac036cf334e52d2a5
Python
3,437
85
from deepcardio.neuralop_core.transforms import DataProcessor from torch_geometric.data import Data class CustomDataProcessorGINO(DataProcessor): def __init__( self, x_normalizer=None, input_geom_normalizer=None, query_normalizer=None, out_normalizer=None ): supe...
7d3856adaa13325d019a29e3a2afbd885676fccd06efa8348a5cd36377fb745d
Python
3,437
76
import torch import torch.nn as nn import torch.optim as optim import Utiliz def train_model_context(round, epoch, ni, args, trainloader_cifar100, target_extend, optimizer_input, optimizer_net, contexts, my_extended_model, criterion): my_extended_model.train() train_loss = 0 correct = 0 total = ...
6f92f886db2bbb47148ab101a7c6820722c2bd67469687538eec9fe10f6acc27
Python
3,440
70
import os,sys import numpy as np from chinn.seq_to_hdf5 import load_bed from chinn.pair_features import load_pairs_as_dict, plot_dist_distr, generate_data, save_data_to_hdf5, load_data_from_hdf5 from chinn.epigenetic_model import train_estimator from sklearn.externals import joblib import argparse if __name__=='__main...
d9327789c4a5c737c20ab0e87b7229037f69ccc6732fd3825c962c26c8356250
Python
3,440
103
from torch.utils.data import DataLoader from geoseg.losses import * from geoseg.datasets.potsdam_dataset import * from geoseg.models.DCSwin import dcswin_small from catalyst.contrib.nn import Lookahead from catalyst import utils from timm.scheduler.poly_lr import PolyLRScheduler # training hparam max_epoch = 30 ignore...
21e1a229d27cb0f08cdb959720ddcd029795c72a92107d1d5bec8633794a4864
Python
3,441
65
# NOTE: # This is a copy of "parula" from MATLAB. We don't claim any rights to this # file, but The Mathworks does. Consult them and/or a lawyer if you want to # use it. from matplotlib.colors import LinearSegmentedColormap cm_data = [[0.2081, 0.1663, 0.5292], [0.2116238095, 0.1897809524, 0.5776761905], [0.21225238...
6bb553b19b4b51dd6b4d6b80695cf0a4154aeceefb5d70bd6f10950bc882ae65
Python
3,441
102
"""Run with QT_QPA_PLATFORM=offscreen python -m tools.benchmark_undo.""" from __future__ import annotations import argparse import collections import json import statistics import tempfile import time from pathlib import Path from unittest.mock import patch import numpy as np from PySide6 import QtCore from PySide6 ...
cef1214926e826466158f820ef71c8c677ecd5a8cad3af6757db57deceef4dda
Python
3,441
89
"""Tests for process_spectra.py""" import numpy as np import pytest import torch from mcmlnet.utils.process_spectra import coeff_of_variation, r_specular class TestRSpecular: """Test cases for the r_specular function.""" def setup_method(self) -> None: """Setup method to initialize common variables...
4092ab7986b565b5466af444ed35d8fc3609d8a997fd18658bece6216dbd9214
Python
3,442
109
from pathlib import Path import tempfile import numpy as np from registrator_base import RegistratorBase from brainles_preprocessing.registration.ANTs.ANTs import ANTsRegistrator from brainles_preprocessing.registration.niftyreg.niftyreg import NiftyRegRegistrator from brainles_preprocessing.registration.elastix.elas...
99467b004fc3e3b9569de4c0864a3edbc97aa42aa030b726805ed503ea093d99
Python
3,442
93
import numpy as np #from scipy import sparse from scipy.io import loadmat import sys import time import nibabel as nib import argparse def argument_parse(): parser=argparse.ArgumentParser() parser.add_argument('--subjects','-s',action='store', dest='subjlist', required=True) parser.add_argument('--fileroo...
b9330aee93eda91b77eeccb9e22709ccac631a0575ae06acd94a7741f0814239
Python
3,442
91
# -*- coding: utf-8 -*- """ Created on Fri Jun 3 15:56:40 2022 @author: Yoshi """ import os import numpy as np from PIL import Image,ImageDraw,ImageFont os.chdir("../map_generators") from cell_drawer import * def rfs_mapper(map_output_path,canvas,width,height,cell_locations,scale,radius,color_key,cell_flags,extr...
cb2e46cb86fefe9c28d08dc5d1a0c9375325d5bd5af4ede9d70432d653af479a
Python
3,442
119
from __future__ import annotations from pathlib import Path from typing import Final import pytest from PySide6.QtCore import QByteArray from PySide6.QtCore import QPoint from PySide6.QtCore import QSize from PySide6.QtWidgets import QMessageBox from pytestqt.qtbot import QtBot from labelme._app import WINDOW_LAYOUT...
2649adb5a56cee6ae16a755326cc75758b442192ef1fe960036d56aca90a089d
Python
3,443
74
from dipy.core.gradients import gradient_table from dipy.io.gradients import read_bvals_bvecs from dipy.io.image import load_nifti, save_nifti from dipy.reconst import mapmri import numpy as np # -------------------------------------------------- # 1. Paths # -------------------------------------------------- fraw = "...
5027efc1d3490893354f657d3726387fc8c43ed31d5e992711cdf42a2e49ebd8
Python
3,445
106
import h5py import os import pathlib import matplotlib.pyplot as plt import numpy as np DIR = os.path.dirname(os.path.realpath(__file__)) HOME_DIR = DIR.rsplit('/', 1)[0] HOME_DIR = HOME_DIR.rsplit('/', 1)[0] print('> HOME: ', HOME_DIR) DATA_DIR = HOME_DIR + '/data/' print('> DATA: ', DATA_DIR) # %% mkdir GIF_DIR ...
5b760acf7c9af0b0f59e599411c20679e8e783a4fec6cc03ec84e5c89bb4ce7d
Python
3,445
91
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Tests for select_pca_features and pca_extract with new parameters. """ import numpy as np import pandas as pd import pytest from pcafeat.select_pca import select_pca_features @pytest.fixture def sample_data(): """Generate synthetic data where a few PCs are stron...
fd01ec4c0e932257302a435fc59aa901a776e226769e650e290b96bc50546e13
Python
3,445
90
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Jun 11 15:26:23 2026 @author: stoutjd """ # ============================================================================ # augmentation_generator.py # Drop into MEGnet/prep_inputs/training/ alongside new_train_model_pkl.py # Env: tensorflow 2.6.2, keras...
ed1d7776f40cb7e9347013c38af81236159e8b4562fdda09519db1a0fa609d4a
Python
3,446
149
r""" This module provides voxel transformations. .. note:: * All randomness under the hood is controlled with PyTorch. * All geometric transformations assume input of shape ``(C, D, H, W)``. """ from itertools import combinations import torch class RandomRotate90: r""" Rotate voxels around a random...
f4252321e09735643f8cc2fae710aae63b50f4836148baff5b99799795cbac45
Python
3,446
104
# -*- coding: utf-8 -*- """ Created on Fri Apr 7 21:58:30 2023 @author: axthi """ import numpy as np import os from simnibs import mesh_io, sim_struct, __version__ from simnibs.utils.file_finder import SubjectFiles from simnibs import localite, brainsight version = [int(x) for x in __version__.split('.')[:3]] isSi...
00733320e4466ac211ffc60c1dc79f0d5e616ca0868e74c4093f6858a87388cf
Python
3,450
122
#!/usr/bin/env python """ RS-232 interface to an ASI tiger controller. Hazen 05/18 """ import traceback import storm_control.sc_hardware.serial.RS232 as RS232 import storm_control.sc_library.hdebug as hdebug class Tiger(RS232.RS232): """ Tiger controller interface class. """ def __init__(self, **kwd...
29b02ce57a34121b435822ebf6634655fca8ff247d4abf68820edb7eec030f31
Python
3,450
92
from pathlib import Path import pandas as pd from brainscore_core.supported_data_standards.brainio.assemblies import BehavioralAssembly from brainscore_core.supported_data_standards.brainio.packaging import package_data_assembly ''' Experiment information - 4 experimental conditions - Texturized stimuli 1 --> '...
3a9657973e83c594e97d8695a93273cb893ffae5f41e6b5175ce6c9c5c34a88a
Python
3,450
96
import numpy as np import matplotlib.pyplot as plt def load_file(fname): data = np.load(fname) dt = 0.1 times = data['times'] idx = np.where(np.diff(times) > 1)[0] idx_end = np.append(idx, len(times)) idx_strt = np.append(0, idx+1) atps = [] pyrs = [] print('At time 0, ATP:', dat...
268df5341a0e3ef4cedaca67890276eb89d79841b439cde09a57e8ff2d5d71c1
Python
3,452
66
''' This file contains functions to produce hdf5 files for training/validation/test. The validation chroms are 5, 14 The test chromosomes are 4, 7, 8, 11 ''' import os,sys import argparse from chinn import variables from chinn.data_preparation_helper import get_and_save_data, load_pairs if __name__ == '__main__': ...
f0d7bf2a1bb43cdf16302e22d77af133563a39d1e8725b7d2c8942c605855215
Python
3,452
78
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import os import tempfile from scilpy import SCILPY_HOME from scilpy.io.fetcher import fetch_data, get_testing_files_dict # If they already exist, this only takes 5 seconds (check md5sum) fetch_data(get_testing_files_dict(), keys=['tractometry.zip']) tmp_dir = tempfile....
0a4306b9a5b28013ac7d6094af0cb0ea7f551bd3c0f01f184f14f708675d41bd
Python
3,453
44
from testsetclass import TestsetClass class ISO34(TestsetClass): def __init__(self): self.weak = 1.0 self.molecules = ['P4', 'P3', 'P2', 'P26', 'P21', 'P28', 'P17', 'E32', 'P10', 'P11', 'E34', 'P29', 'E33', 'P16', 'P20', 'P18', 'P27', 'E5', 'E20', 'E27', 'E18', 'E11', 'P34', 'P33', 'E16', 'E29', '...
09ce5e4e74d27b723983db469f65478cd5e0ece78de8c5ff8e466adde93d5ed5
Python
3,454
127
###################################################### ### Averages early- and late-phase weight matrices ### ###################################################### ### Copyright 2019-2022 Jannik Luboeinski ### licensed under Apache-2.0 (http://www.apache.org/licenses/LICENSE-2.0) ### Contact: mail[at]jlubo.net impor...
68ed1c810869e6a1aeea6d993aad68c01e978e917ffeb297dc63993c0c5e7bbd
Python
3,454
89
import os import sys import torch import random import logging import traceback import numpy as np class InfiniteDataLoader(torch.utils.data.DataLoader): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.dataset_iterator = super().__iter__() def __iter__(self): ...
89d62476e119a9a73f70b0f5a6908f4e76c54d808a14d427f0d85742caa4b161
Python
3,454
111
# Copyright (c) DP Technology. # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from collections import OrderedDict import torch from torch.utils.data.dataloader import default_collate from...
6eacd0f022d6aae65ebdb05bae719f01f57e9f97ce4dd41ea77b0a2c9f3a47f5
Python
3,455
85
from deepcardio.neuralop_core.transforms import DataProcessor from torch_geometric.data import Data class CustomDataProcessorGINO(DataProcessor): def __init__( self, a_normalizer=None, input_geom_normalizer=None, query_normalizer=None, out_normalizer=None ): supe...
ac4e110d709ca41325f79785f823afa893bde1e3a47068c0fdedb79908965a6a
Python
3,455
90
# This file was automatically generated by SWIG (http://www.swig.org). # Version 4.0.2 # # Do not make changes to this file unless you know what you are doing--modify # the SWIG interface file instead. from sys import version_info as _swig_python_version_info if _swig_python_version_info < (2, 7, 0): raise Runtime...
27db0f6a86ea2c10875fa4ed73ea16117238c04210a83c464a0c886de6443d50
Python
3,457
88
import argparse import torch from torch_sparse import transpose from torch_geometric.nn import MetaPath2Vec from ogb.nodeproppred import PygNodePropPredDataset @torch.no_grad() def save_embedding(model): embedding = model('paper').cpu() torch.save(embedding, 'embedding.pt') def main(): parser = argpar...
70a9fb99702f4a9f0c92bd5faa345253e3fc1f8323823b7701fb3d97395d7e49
Python
3,457
107
import numpy as np from scipy import ndimage def h(pvals): return 2*(pvals > 0.5).astype(float) def s(pvals): return 1-pvals def g(pvals): return np.minimum(pvals, s(pvals)) def sinv(tdpvals): return 1-tdpvals def sdot(pvals): return -1 def fdp_hat(pvals, mask): if np.sum(mask) == 0: ...
d6e93791d6c5bdc0b3754634b70f464c26e41ce86069ed4e600976110f1ceded
Python
3,458
127
###################################################### ### Averages early- and late-phase weight matrices ### ###################################################### ### Copyright 2019-2022 Jannik Luboeinski ### licensed under Apache-2.0 (http://www.apache.org/licenses/LICENSE-2.0) ### Contact: jannik.lubo[at]gmx.de i...
7779f99b371ca24cdbf23f92756f1ec840773da783ae8f0cff2c1a5ec5bb0434
Python
3,460
119
###################################################### ## Template script to train a MOFA+ model in Python ## ###################################################### from mofapy2.run.entry_point import entry_point import pandas as pd import io import requests # to download the online data ############### ## Load data...
85a3654d5bb6915332f172bbb4396f19fd7655d7a84c3e2e742e8c208e3ecdfa
Python
3,460
122
import torch.nn as nn import torch_geometric.nn as gnn from torch_geometric.data import Data __all__ = ['GNNTracker'] class GNNTracker(nn.Module): """Graph neural network node classifier. based on : https://github.com/pyg-team/pytorch_geometric/blob/master/examples/ogbn_proteins_deepgcn.py Attributes ----------...
5c0d24935e9d3b7db29f0978cf07fb0b7bab5474ce1d52de290d1900c2886b1a
Python
3,461
63
single_agent_prompt = """You are an expert in computational chemistry, using advanced tools to solve complex problems. Instructions: 1. Extract all relevant inputs from the user's query, such as SMILES strings, molecule names, methods, software, properties, and conditions. 2. If a tool is needed, call it using the cor...
de92ab1d22512c30d5b18a9c349243c276fbf366f1bce89834b45f11d041839b
Python
3,461
83
from pathlib import Path import pytest from pytest import approx from brainscore_vision import benchmark_registry from brainscore_vision.benchmark_helpers.test_helper import StandardizedTests, PrecomputedTests, NumberOfTrialsTests from brainscore_core.supported_data_standards.brainio import s3 standardized_tests = S...
0479aeb89911b219b2e2ee458d6b7ee6be23daf0d3d45c4ab54ca4ddff045856
Python
3,463
85
from deepcardio.neuralop_core.transforms import DataProcessor from torch_geometric.data import Data class CustomDataProcessorGINO(DataProcessor): def __init__( self, a_normalizer=None, input_geom_normalizer=None, query_normalizer=None, out_normalizer=None ): supe...
56bb3820ee43fb13332c9fa3f72b6e94c23d3c158afde72e01c40c0618b41f9a
Python
3,463
112
import brainpy as bp import brainpy.math as bm import numpy as np import jax import seaborn as sns import matplotlib.pyplot as plt from cann import CANN1D import scipy from scipy.stats import ttest_ind #set default ramndom seed for reproducibility np.random.seed(0) #set backend to cpu bm.set_platform('cpu') cann = CAN...
f97ab3a5b9972572dc1635f0b1077ec79ae762874b40a928d436d342eb047827
Python
3,463
85
import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns from scipy.cluster.hierarchy import dendrogram, linkage import sys def get_newick(node, parent_dist, leaf_names, newick='') -> str: """ Convert sciply.cluster.hierarchy.to_tree()-output to Newick format. :param n...
cbb503b38c900673790e40d3fb7caf661c495929c024bc96d1911e85f7bb1406
Python
3,464
95
"""Academy Agents integration for ChemGraph. Public re-exports come in two tiers so the package honours the ``[academy]`` optional-dep contract: * **Eager** (pure stdlib + pydantic, always importable): ``ChemGraphAgentSpec``, ``ChemGraphCampaign``, ``ChemGraphDaemonConfig``, ``MCPServerSpec``, ``ResourceSpec``, ...
11c6b9f46ae1d8931d944aa31a9c982e1f440bcd77e3b59f1bff68d892fc4edf
Python
3,465
109
import torch from torch.utils.data import DataLoader from torchvision import transforms import pytorch_lightning as pl from pytorch_lightning.loggers.neptune import NeptuneLogger from pytorch_lightning.callbacks import ModelCheckpoint from torchmetrics import MetricCollection, AUROC, AveragePrecision import yaml imp...
553eca74d2b390d507ce712dc355d4486173ea25e1fae512b0e21c6902781dbf
Python
3,465
102
from __future__ import division import numpy.ma as ma import numpy as np import scipy as s import math from mofapy2.core.utils import dotd from mofapy2.core import gpu_utils # Import manually defined functions from .variational_nodes import Constant_Variational_Node class Y_Node(Constant_Variational_Node): def _...
754214051fa811f3845c123d3e2aba1c1c56fc3698f4d7edacee7e4435ffed6b
Python
3,465
96
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Clean a bundle (inliers/outliers) using hiearchical clustering. http://archive.ismrm.org/2015/2844.html If spurious streamlines are dense, it is possible they will not be recognized as outliers. Manual cleaning may be required to overcome this limitation. """ import ...
156c7fa3dd6f617c9d304e83a665d7efef592490219a816bd9250c4546715b95
Python
3,466
110
import pytest from scilpy.utils.scilpy_bot import ( _make_title, _get_docstring_from_script_path, _split_first_sentence, _stem_word, _stem_keywords, _stem_text, _stem_phrase, _highlight_keywords, _get_synonyms, _extract_keywords_and_phrases, _calculate_score ) have_nltk = True @pytest.mark.skipif(no...
171561ae411514cd9e8c20a1dd25a66ccd739de47d792ede169228af7239c795
Python
3,466
103
# -*- coding: utf-8 -*- """ Transform time series to target space In the following script, epi time series in native space are transformed to a target space using a deformation field. The transformed time series get the prefix r. Because of heap size limits, the time series is split and the deformation is applied sepa...
33657a3dc75afc6aae851479b80628532443269d74c9892298372680934f1332
Python
3,466
89
#!/usr/bin/env python3 # StrabismusClassification/scripts/plot_per_label_roc.py import importlib.util from pathlib import Path import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.metrics import roc_curve, roc_auc_score from sklearn.utils import resample def load_config(project_root: ...
b8eedd664669e4800318f9509e08fdbb364c60d99ad7eec40afe3de6b3061c91
Python
3,467
95
import numpy as np import matplotlib.pyplot as plt def load_file(fname): data = np.load(fname) dt = 0.1 times = data['times'] idx = np.where(np.diff(times) > 1)[0] idx_end = np.append(idx, len(times)) idx_strt = np.append(0, idx+1) atps = [] pyrs = [] print('At time 0, ATP:', data...
c24708cbfe1236bfa7649e16df86c65523f59929db8e272f269493e5e7cdcd9c
Python
3,467
58
#!/usr/bin/env python # -*- coding: utf-8 -*- # *************************************************************************** # # Copyright © 2022, UChicago Argonne, LLC # # All Rights Reserved # # Softwar...
2d822f108863c6e8e8a3cb25b82ddc6e9aa4f950bea665df5a18b440499db880
Python
3,468
100
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Split a label image into multiple images where the name of the output images is taken from a lookup table (ex: left-lateral-occipital.nii.gz, right-thalamus.nii.gz, ...). Only the labels included in the lookup table are extracted. IMPORTANT: your label image must be o...