sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
8867f0268cbc8b02868a3af6c91605c433f879537bf25d464185cfc36abbdd51
Python
3,237
113
#!/usr/bin/python # ## @file # # Control a Edmunds high speed filter wheel. # # Hazen 02/14 # import os import socket import subprocess import time import win32com.client class HSFW(): def __init__(self): #self.excel = win32com.client.Dispatch("Excel.Application") #self.excel.Visible = 1 ...
ec3f61d0aef32d88e5a8b877d8f19556a4472297da0677f6a354579f4ab08fa0
Python
3,238
109
import h5py import os 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) # %% f = h5py.File(DATA_DIR + '/0....
15e7a1d4804357c832efbf68745d3da93ba406e413bec363eaf31006b64cd3ab
Python
3,239
96
#!/usr/bin/env python3 # imports import argparse from ase import Atoms from ase.io import read, write from ase.optimize import * from ase import units from ase.md.velocitydistribution import MaxwellBoltzmannDistribution, ZeroRotation, Stationary from ase.md.langevin import Langevin from ase.io.trajectory import Trajec...
4f5193db1d9ac5aef8293d630b84723f9a6a4c7584a3dae97df6675dc6bc4e09
Python
3,240
85
import logging from typing import Generator, Callable, List, Tuple, Any from zigzag.classes.stages.Stage import Stage from zigzag.classes.cost_model.cost_model import CostModelEvaluation logger = logging.getLogger(__name__) class GeneralParameterIteratorStage(Stage): """ General iterator over any parameter ...
6afef497781eadc1644d043f050e7ab60f394c6d9140dbfe74d2aac143b62c14
Python
3,240
103
# -*- coding: utf-8 -*- # python standard library inputs import os import shutil as sh # external inputs import numpy as np import nibabel as nb from nighres.laminar import profile_sampling # local inputs from ..io.affine import read_vox2ras_tkr from ..cmap.generate_coordinate_mapping import generate_coordinate_mapp...
dc16a34fde0e26c970f8c4aba902d107aed22d3da96e16f6bea8f40ad38a37ac
Python
3,240
97
import torch import torch.nn as nn class AsymmetricLossMultiLabel(nn.Module): def __init__(self, gamma_neg=4, gamma_pos=1, clip=0.05, eps=1e-8, disable_torch_grad_focal_loss=False): super(AsymmetricLossMultiLabel, self).__init__() self.gamma_neg = gamma_neg self.gamma_pos = gamma_pos ...
eac7ccd58b62ad4c410bb364b4a1c13437348c21fb89decac0a109d42555402d
Python
3,240
87
import os import numpy as np import nibabel as nib import matplotlib matplotlib.use("Agg") # 防止GUI后台冲突 import matplotlib.pyplot as plt import imageio # ======== User settings ======== flair_path = r"F:\BIDS\demo_BIDS\derivatives\xfm\sub-AFib0241\ses-baseline\sub-AFib0241_ses-baseline_acq-highres_space-T1w_desc-brain_...
f76d6b82927bc2f6f434a3f636fbf3871da24bf6abc4f76ab726c108831c281c
Python
3,240
88
import pandas as pd import torch import os.path as osp import numpy as np import dgl from ogb.io.read_graph_raw import read_csv_graph_raw, read_csv_heterograph_raw, read_binary_graph_raw, read_binary_heterograph_raw from tqdm import tqdm def read_graph_dgl(raw_dir, add_inverse_edge = False, additional_node_files = [],...
5e632237c80a42e0cff0499a4d287723fd73dd7fbc04f0df2a770f5ee5faba86
Python
3,241
69
import base64 import json import os import os.path as osp import numpy as np import PIL.Image from labelme import utils ''' 制作自己的语义分割数据集需要注意以下几点: 1、我使用的labelme版本是3.16.7,建议使用该版本的labelme,有些版本的labelme会发生错误, 具体错误为:Too many dimensions: 3 > 2 安装方式为命令行pip install labelme==3.16.7 2、此处生成的标签图是8位彩色图,与视频中看起来的数据集格式不太一样。 ...
e9d4d56d65f4e2569e9913fe6453cc4baca6459b516bccd8176d9009797f9b8c
Python
3,242
83
from typing import Optional from torch import Tensor import torch_geometric.typing from torch_geometric import is_compiling from torch_geometric.typing import pyg_lib from torch_geometric.utils import scatter, segment from torch_geometric.utils.num_nodes import maybe_num_nodes def softmax( src: Tensor, inde...
2105b5e6b57a3e88376facb9c1ed87cbf91b667c1fbaa18104569cb81174f5a7
Python
3,243
70
"""Reconstruct a high-resolution, display-oriented AAL subcortical surface. Unlike mesh-only smoothing, this starts from the labelled volume and uses a Gaussian-smoothed occupancy field. The resulting isosurfaces do not retain the voxel-grid ripples found in a direct label-to-mesh conversion. """ from __future__ imp...
5cc411b63d5086c7f5d478cf234e305b2c4064997b469bcc8dd79c13e7fbce86
Python
3,243
91
import numpy as np from numba import njit from EPGMotion import * from Jacobian_MotionCorrection import * @njit() def EPGForwardMotionModel(theta, opt): # Cache frequently used values nTR = opt["nTR"].astype(np.int32)[0] steadyStateTR = opt["SteadyStateTR"].astype(np.int32)[0] nDummy = opt['nDummy'].as...
80e4f8689364d8e2f124b6187355185262bb462446198d6c590d27a7a9ab4c0d
Python
3,243
96
import argparse import pickle import h5py import nibabel as nb import numpy as np import pandas as pd def get_nearest_point(idxs_res, idxs_to_impute): nearest_point = { tuple(idx): _get_nearest_point(idx, idxs_res) for idx in idxs_to_impute } return nearest_point def _get_nearest_point(target, c...
dd53d1b7fe84f79e00a190fad79af624992e0be39a204e42973e4deb9647cc3c
Python
3,243
108
from .. import fixtures import unittest import arbor as A from arbor import units as U """ tests for (dynamically loaded) catalogues """ class recipe(A.recipe): def __init__(self): A.recipe.__init__(self) self.tree = A.segment_tree() self.tree.append(A.mnpos, (0, 0, 0, 10), (1, 0, 0, 10),...
f5d5190d4a9b1f84ca2cffebe01fae0d60271f8719f46898ad26e791583b5d0f
Python
3,243
94
# This file is part of Mooney computational modeling project. # # Mooney computational modeling project 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 the License, or # (at your option) an...
8ce2edc0e5ec4827d8e2e6456bf2669e58e085eeb8cbf08c589412f468681e43
Python
3,244
129
# -*- coding: utf-8 -*- # external inputs import numpy as np from numpy.linalg import norm def _face_area(v, f): """Helper function to compute face areas.""" # indexed view into the vertex array tris = v[f] a = np.cross(tris[::, 1] - tris[::, 0], tris[::, 2] - tris[::, 0]) a = norm(a, axis=1) ...
f68d00eb646336af762e999cf2ce77d2a2149154acca6117dcdffb3dc4f36975
Python
3,245
111
""" Test hierarchical agglomerative clustering algorithms for comparison """ import numpy as np import scanpy as sc import pandas as pd import squidpy as sq import os import matplotlib.pyplot as plt import seaborn as sns import random import nest from nest.synthetic.data import create_synthetic_data from anndata imp...
1f0db6c10a3651d46d2cbaebe5a47ab5537ce0b365a7859c509840b8607052d0
Python
3,246
91
from collections.abc import Sequence from dataclasses import dataclass from typing import Literal @dataclass class ArrayOutputTypeConfig: """ :param normalization: Which type of normalization to apply to the array data. If ``element``, will normalize each element in the array independently. If...
c6505d73d940c75b865fe57add150d192f06681fb718d465f79b6bb35c92436a
Python
3,246
76
from .CostModelStage import CostModelStage from .DumpStage import DumpStage from .PlotTemporalMappingsStage import PlotTemporalMappingsStage from .SaveStage import CompleteSaveStage, SimpleSaveStage, PickleSaveStage from .MPISaveStage import MPICompleteSaveStage, MPISimpleSaveStage, MPIPickleSaveStage from .GeneralPara...
016d284bc1d3da550ba31734cda2652d21ff370c510b5f643578f3bc0f8631a7
Python
3,247
99
#!/usr/bin/env python3 import bisect; def getSegs(pos,seglen,direction,exonstart,exonlen): """ This function returns the corresponding segstart and seg length (as in the list) parameters: pos: the position to be queried seglen: the length of the segment direction: 1 (forward), -1 (backward) exonstart,ex...
9ddd8ae49dbaabb29d9674e49e7ffe952ddade35a0a85faa84d87a251ee49c5a
Python
3,247
94
"""Ordered endpoint registry and side-effect-free model selection helpers.""" from __future__ import annotations from chemgraph.models.endpoints import EndpointSpec, ModelRequest from chemgraph.models.endpoints import alcf as alcf_ep from chemgraph.models.endpoints import anthropic_direct as anthropic_ep from chemgra...
966b0186df02d217db6d7a1429906972a8e040a0d7caa2edf2dd9daf97a2d457
Python
3,248
105
import random from dataclasses import dataclass from pathlib import Path from typing import TYPE_CHECKING import numpy as np from PIL import Image from tests.setup_tests.setup_modelling_test_data.setup_targets_test_data import ( get_current_test_label_values, get_test_label_file_fieldnames, set_up_label_f...
ab976a82638e67056c27a9777155f9f281921d677a2bd6a581f68c905d97d8ad
Python
3,248
99
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved import torch def recursive_fn_factory(fn): def recursive_fn(b): if isinstance(b, dict): return {k: recursive_fn(b[k]) for k in b} if isinstance(b, list): return [recursive_fn(t) for t in b] if...
24b81f0b4b68236aa2817972966441aabc1da9c16ec6063b45c076d92a9d21c1
Python
3,249
105
import warnings import torch from torch import Tensor import torch.nn as nn import torch.nn.functional as F from typing import List, Union, Tuple, Optional from functools import partial from bism.modules.upsample_layer import UpSampleLayer2D from bism.modules.concat import ConcatConv2D """ Re-implementation of Cellp...
1ea36e4960daad36e72012f4f0679e135f5b33336a028893d603bc2627563920
Python
3,251
83
"""Compare MATLAB vs Python spike detection on the parity run. Reports per-recording spike counts and the match rate within +/-1 ms, plus the exact per-spike time offset once counts agree. Note the known, deliberate 2-sample offset: MATLAB's spike times sit 2 samples after the true negative peak (1-based frames + ali...
61a46286c461801763cc8c001d159498c721292933ffbb7f82789a9741842f99
Python
3,251
106
""" bootstrap_eval.py ----------------- 在完整训练集上反复自举 (B=1000) 评估 MLP,输出 95% 置信区间。 """ import json from pathlib import Path import numpy as np import pandas as pd import torch import torch.nn as nn from torch.utils.data import Subset, DataLoader from dataset import StrabismusDataset from models.mlp_model import Surgery...
b1f62c9750adac14149c0472bb6353c297aa93dad05aeb76c55bc1207f50ba7a
Python
3,251
87
from pathlib import Path from brainscore_core.supported_data_standards.brainio.stimuli import StimulusSet from brainscore_core.supported_data_standards.brainio.packaging import package_stimulus_set stimuli = [] image_paths = {} stimuli_directory = '../datasets/false-colour/dnn/session-1' ''' Dataset Meta Info (from h...
f55ef0f44fb5fff9c9afd361353119f8faf5601f9a8212458ab63e2bc4a02154
Python
3,251
97
import os import time import copy import argparse import torch import torchvision from torchvision import datasets, transforms, models from torch.utils.data import DataLoader, random_split import matplotlib.pyplot as plt import seaborn as sns import numpy as np from classification.ResnetClassification import ResnetClas...
a06731b704ad0b3a32f57ff1d116ccae6f379f527a7c5d00b7374b32930731a8
Python
3,252
93
# This file is part of connectome-manipulator. # # SPDX-License-Identifier: Apache-2.0 # Copyright (c) 2024 Blue Brain Project/EPFL import numpy as np import pytest from mock import patch, Mock from numpy.testing import assert_equal from utils import create_fake_module import connectome_manipulator.connectome_compari...
bc9f9090c2eb5366c7bcdf8f8f0ae18f66ef2ca86b7ec3caddf8d5c166b497d5
Python
3,252
91
from src.wrappers.OsipiBase import OsipiBase from src.original.fitting.DT_IIITN.wls_ivim_fitting import wls_ivim_fit import numpy as np class DT_IIITN_WLS(OsipiBase): """ Segmented IVIM fitting with selectable regression method. Two methods are available: - WLS: Weighted Least Squares with Veraart S²...
1e7ef298a0053b45961c7c88fb6a5990f04b730815d4c1af05e82ccba8ce9e1c
Python
3,253
75
import os, argparse, subprocess, sys import nmrglue as ng import numpy as np import MRAi_P3 as P3 ##################################################################### def parse_input_file(filename): params = {} with open(filename) as f: for line in f: line = line.strip() if not ...
90f026d5b5a12c5a52f3cf1978fb67d4ea10ea138f7967ecb395396ca92084ca
Python
3,253
99
import nibabel as nib import numpy as np import numpy.testing as npt from scipy.ndimage import distance_transform_edt import AFQ.recognition.roi as abr import AFQ.recognition.utils as abu from AFQ.recognition.roi import check_sl_with_exclusion, check_sls_with_inclusion shape = (15, 15, 15) affine = np.eye(4) streaml...
e66561346e561a1bd427d862d0c035f69314e39e0680ebaad225f555784bfe9d
Python
3,253
89
_base_ = [ 'RepLKNet_cascade_mask_rcnn_coco.py', '../_base_/datasets/coco_instance.py', '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py' ] model = dict( backbone=dict( large_kernel_sizes=[27,27,27,13], channels=[256, 512, 1024, 2048], small_kernel=None, ...
f604e4d14ea2a2bd2a603c59da0d1fc972f2c85ac7ec88caea95dfd5a9b071ed
Python
3,253
84
# wfield - tools to analyse widefield data - hemodynamics correction # Copyright (C) 2020 Joao Couto - jpcouto@gmail.com # # 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 ...
f8165e4f69ba86f43a90ec6e723d4700c46a79223aa6dec4f4a2228925204274
Python
3,253
83
############################################################################# # Copyright (C) 2020-2026 MEmilio # # Authors: Carlotta Gerstein # # 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 ...
0663d462d1ffc6c4f30c38bad3d9ae889034f6f613bead18d30954a34348d878
Python
3,254
72
import functools from brainscore_vision.model_helpers.activations.pytorch import load_preprocess_images from brainscore_vision.model_helpers.check_submission import check_models from brainscore_core.supported_data_standards.brainio.s3 import load_weight_file from brainscore_vision.models.mobilenet_v2_0_5_192.model impo...
1684f6f4d309b670bec065fc4c5134282907d72a6b8a60cda8e8f08386e959ba
Python
3,254
73
""" :class:`~allennlp.common.registrable.Registrable` is a "mixin" for endowing any base class with a named registry for its subclasses and a decorator for registering them. """ from collections import defaultdict from typing import TypeVar, Type, Dict, List import logging from stog.utils.checks import ConfigurationEr...
07ff374b2c53e8eb5897c4be7cc80c615f7a46ba92649b02592a984582bc0bfc
Python
3,255
93
''' 利用Conv2former结构作为链接构建一个PFA结构,这个结构要包含norm操作,我们最后替换的是模型中的norm结构 ''' import torch import torch.nn as nn from Conv2Former import Dual_ConvMod,Dual_Block import torch.nn.functional as F class LayerNorm(nn.Module): r""" From ConvNeXt (https://arxiv.org/pdf/2201.03545.pdf) """ def __init__(self, normalized_...
2e150080a4bf83f4c2800681535d0e445e6d6ed00bc1066afc6ccd4d108992b7
Python
3,255
83
#!/usr/bin/env python3 """Generate a synthetic Thalamus capture (``.tha``) file with no hardware. This writes a recording that looks just like one produced by a STORAGE2 node: a leading metadata record followed by a series of analog records. Two channels are generated -- a 2 Hz sine wave and a 1 Hz square pulse -- so...
428e0ad792924583d9eb502a0390035786c2d65c6497ad0c95ac9a4f901f5d40
Python
3,255
105
from __future__ import annotations from dataclasses import dataclass from typing import Tuple import kornia.geometry as KG import kornia.geometry.transform as KGT import kornia.utils as KU import numpy as np import torch import torch.nn.functional as F from torch import Tensor from brainways.transforms.base import B...
8466e0c94165f4af67b764101231860fc9921ef75ccd4da0d5d5687663795633
Python
3,255
65
from brainscore_core.supported_data_standards.brainio.fetch import get_assembly from brainscore_core.supported_data_standards.brainio.packaging import package_data_assembly, package_stimulus_set def adapt_stimulus_set(assembly, name_suffix): stimulus_set_name = f"{assembly.stimulus_set.name}-{name_suffix}" as...
8bb877cfae3ec591c8b786e641b8b2b0af81b3f32f2105ab9015c44d4f93c691
Python
3,255
109
''' H3S ''' import numpy as np import sys def intro(): print(""" SHORT List of potential energy surfaces for H3S: 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 g...
367780e5370b0e0ef40b3a31c4062cf2db3e90f1c8da39ab110e7e28b0eebc0d
Python
3,256
98
#!/usr/bin/env python3 # imports import argparse from ase import Atoms from ase.io import read, write from ase.optimize import * from ase import units from ase.md.velocitydistribution import MaxwellBoltzmannDistribution, ZeroRotation, Stationary from ase.md.langevin import Langevin from ase.io.trajectory import Trajec...
414d6abcb2716234878a76b14e796cf24a22d63cfaa334f8a687e7d6ed63cca8
Python
3,256
101
r""" This module provides PyTorch modules for voxel-based processing. """ import torch from torch import nn def conv3d_block(in_channels: int, out_channels: int, **kwargs): r""" Return a block of the form Conv -> BatchNorm -> ReLU. Examples -------- >>> block = conv3d_block(4, 8, kernel_size=2, ...
83effa58fc0a6856ae0732728f5012736ef05f30f69870ac6606654b6d1cd7b6
Python
3,256
103
import base64 import json from unittest.mock import MagicMock, patch import pytest from pyment.utils.download_file import download_file def make_mock_response(chunks: list[bytes], content_length: int = 0): response = MagicMock() response.headers.get.return_value = content_length response.iter_content.re...
17dba1c2d1147204075dc5b4bcf9ad54fd8cc6b7cb09e8c3bc45fcf42d75c0bd
Python
3,257
93
import os import numpy as np parallel_starts = 8 available_gpus = ['6,1', '6,1'] # args dict args_dict = {'device': 0, # gpu 'log_steps': 1, 'num_layers': 3, 'hidden_channels': 256, 'dropout': 0.0, 'batch_size': 64 * 1024, 'lr': 1.e-03, 'ep...
828daf9081f2b0456f1e9124f6c64a2a215fadf51574765f95664802d2316661
Python
3,257
94
import ot import numpy as np import scipy.sparse as sp from sklearn.neighbors import NearestNeighbors import torch def construct_interaction(position, n_neighbors=3): """Constructing spot-to-spot interactive graph""" # calculate distance matrix spot distance_matrix = ot.dist(position, position, metric='e...
8547c9340cc0186c4cad61a428af4e7f5b7794655cf28f7abde950f63df2e809
Python
3,257
107
""" Loader for Calcium & TTX/NBQX Datasets ===================================================== This module allows loading multi-frame TIFF recordings from: 1. Calcium dyes: calbr, cal520, fluo4, fluo8, ef630 2. TTX/NBQX datasets: ttx, nbqxap5 Examples: --------------- # Calcium dataset stack = load_recor...
89a67afe88e20c820b878b0c2926756897fcf51928ced845f10466debe9fb7ba
Python
3,257
99
# -*- coding: utf-8 -*- # python standard library inputs import os # external inputs import numpy as np import nibabel as nb from nibabel.freesurfer.io import read_morph_data from scipy.ndimage.filters import gaussian_filter def map2grid(file_grid, file_input, sigma, path_output="", basename_output="", ...
1323f7112098307f81b24ef594b9666636665dab751c7766cc464af8aed643f9
Python
3,258
85
# Copyright (C) 2021-2022 Intel Corporation # # SPDX-License-Identifier: MIT from django.conf import settings from django.contrib.auth.models import Group from django.db.models.signals import post_migrate, post_save def register_groups(sender, **kwargs): # Create all groups which corresponds system roles for...
26b4cddd6d6cadd90d5fba980c6074f26639eb5e62e677c42524c701d77912e0
Python
3,260
101
from enum import Enum from typing import List, Optional, Union import torch import torch.nn.functional as F from torch import Tensor class PoolingStrategy(Enum): MEAN = 'mean' LAST = 'last' CLS = 'cls' class SentenceTransformer(torch.nn.Module): def __init__( self, model_name: str, ...
4c9054612f8f70afa81365a2938a6a2d1df5762375cc9dc9d985f5bd748effa8
Python
3,260
98
#!/usr/bin/env python3 # imports import argparse from ase import Atoms from ase.io import read, write from ase.optimize import * from ase import units from ase.md.velocitydistribution import MaxwellBoltzmannDistribution, ZeroRotation, Stationary from ase.md.langevin import Langevin from ase.io.trajectory import Trajec...
fb0dae41e902687e886bfadac832804eaebf8775de2d0a55f8174d61f05311dd
Python
3,260
76
import cv2 import numpy as np CLASS_NAMES_GEOMETRIC = { 1: 'rectangle', 2: 'triangle', 3: 'ellipse' } def random_triangle(image, mask, x, y, color, radius_range=(3, 28)): a, b, c, d, e = np.random.randint(*radius_range, size=5) triangle_cnt = np.array([[x, y - a], [x + b, y + c], [x - d, y + e]])...
ea34a01183eeb4ef1c77ef43145d9eefb44fbfce7e56b2976e51ae851f02be22
Python
3,261
82
# Generated by Django 3.2.15 on 2022-09-27 12:28 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ("webhooks", "0001_initial"), ] operations = [ migrations.AlterField( model_name="webhookdelivery", name="status_code...
102497191b2c4b90be1b22321022fc830372eb786d60f70a67713a223d9eb3c0
Python
3,262
86
import torch from torch_geometric.nn import MessagePassing from torch_geometric.nn import global_add_pool, global_mean_pool, global_max_pool, GlobalAttention, Set2Set import torch.nn.functional as F from torch_geometric.nn.inits import uniform from conv import GNN_node, GNN_node_Virtualnode from torch_scatter import ...
abea09db2f3f38afb87c39b2aef8ff2a6ecc171c971818f8ef444dc1eabd56f1
Python
3,262
89
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Compute the mean Apparent Fiber Density (AFD) and mean Radial fODF (radfODF) maps along a bundle. This is the "real" fixel-based fODF amplitude along every streamline of the bundle provided, averaged at every voxel. Please use a bundle file rather than a whole tracto...
d28984355dc3e8b1563a2a5e0b7e10a467b8e3788c3ff0f9601b544d942fb111
Python
3,262
83
import click import dolfin as df import numpy as np import pantarei as pr @click.command("refine_mesh") @click.option("--input", "-i", type=str, required=True) @click.option("--output", "-o", type=str, required=True) @click.option("--threshold", "-t", type=float, default=2.0) @click.option("--function", "-f", "functi...
ebb19a4236e41903b7db193e367f9613823c0ff3120bb948e5ff735544c46a7a
Python
3,262
109
''' List of default values and description of the tierpsy.processing.progressMultipleFilesFun ''' import os from tierpsy import IS_FROZEN from .helper import repack_dflt_list #get 90% of the number of cores as the default max_num_process import multiprocessing as mp _max_num_process = max(1, int(mp.cpu_count()*0.9))...
ab79ee6a90ad8fed39a0e62caad86e0171c7f6cd87611514796f30faf10a72c5
Python
3,263
106
import re import os import requests # def parse_a2m(a2m_content,protein_name): # a2m_lines = a2m_content.strip().split('\n') # sequence_dict = {} # for line in a2m_lines : # if line.startswith('>') and '>'+protein_name+'/' not in line: # uniprot_id = re.search(r'\|([A-Za-z0-9]+)\|',...
f24f5fd2a3531f5f471a8356598cd1b9ae71d7c65e1dae687f4c95d02f1f033e
Python
3,263
92
import torch from distances import CosineSimilarity from reducers import DivisorReducer from utils import common_functions as c_f from utils import loss_and_miner_utils as lmu from losses.base_metric_loss_function import BaseMetricLossFunction from losses.mixins import WeightRegularizerMixin # adapted from # https:/...
ff853c5a3bef969e06c410b52032c51d66546538e486ccf1725c8dcf0f2e6954
Python
3,263
93
from typing import Literal, Final import polars as pl from argclz import argument, as_argument from neuralib.plot import plot_figure from neuralib.util.verbose import publish_annotation from rscvp.statistic.core import StatPipeline from rscvp.util.cli.cli_statistic import StatisticOptions from rscvp.util.database imp...
8416fe0b94f788419435c9126db682fe9afbed255836e4a85d6ecdfb35bd0a73
Python
3,265
84
import tensorflow as tf from tensorflow import keras from utils import data_utils, argmanager from utils.loss import multinomial_nll import numpy as np import os import json import scipy import sklearn.metrics import scipy.stats from collections import OrderedDict def softmax(x, temp=1): norm_x = x - np.mean(x,ax...
d27b4270a82489d813476ff3d73c61cc1aa2052e310f70cb2955548be818e19e
Python
3,265
84
""" Metrics to assess performance of direct-outcome (counterfactual prediction) models. Function named as ``*_error`` return a scalar value to minimize: the lower, the better. Metrics' interface doesn't strictly follow skleran's metrics interface. The outcome prediction is expected to be full potential outcome predict...
4790345e54678c3d7589c2b8878c7c5e9f84ca1f59aa79f57f4441dd14fb6930
Python
3,266
105
import h5py import os 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) # %% f = h5py.File(DATA_DIR + '/0....
39c0564a803a41e29e9ac2d81c5a8fc94fe2abdabb8a6a4154ac1e71fd671112
Python
3,267
103
#!/usr/bin/env python import numpy as np import pandas as pd import click as ck import sys from collections import deque, Counter import time import logging from utils import FUNC_DICT, Ontology, NAMESPACES from matplotlib import pyplot as plt logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.INFO...
6dbfb8be71c696bf72cbefc4ca12ad5f5dccccf13fc7401ce2b0ff939868a357
Python
3,267
86
import yaml import os import sys import h5py import numpy as np from numpy import array pathpath = 'PATHS/filepaths_carlen.yml' myrun = 'runCrespZI_brain' cmethod = 'ward' label_sorter = {'runC00dMP3_brain':{9:np.array([5,1,7,2,3,4,8,9,6])-1,\ 8:np.array([4,1,6,2,3,7,8,5])-1,\ ...
9a33c7728f78e0cc925f56a5a83e3d736454beb9893666ec55b41112b05837c2
Python
3,267
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...
ad622b6dd75e094c5085b267e2ad89d76f64266f6c01b3d5378fa6f04073009e
Python
3,267
87
import shutil from pathlib import Path from typing import Callable, Dict, List import importlib_resources import numpy as np from PIL import Image from brainways.pipeline.atlas_registration import AtlasRegistration from brainways.utils.atlas.brainways_atlas import BrainwaysAtlas from brainways.utils.config import loa...
30805e62bbb6984cebd5c20c40e85c136a4c7729a0468b532885eae646219c4a
Python
3,268
103
# 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 in writing, software # distributed under th...
8986818b83ff50ea0470b8630cae22058e88b611464f11d937dffb232d8147fa
Python
3,268
76
import numpy as np from helper_functions.cell_type_lib import CellType import matplotlib.pyplot as plt import json import pathlib from helper_functions import __file__ MODULE_BASE = pathlib.Path(__file__).parent.parent if __name__ == '__main__': SAVE = True save_path = MODULE_BASE.joinpath('tests/terminal_ani...
e1438ca45a7f3e33d86ab5cf11a812fc79228f6bf2b96025a088085f8e442daa
Python
3,268
105
import types import typing from collections.abc import Callable from copy import copy from functools import lru_cache, partial from importlib import import_module from typing import Any, Union, get_type_hints try: from toolz import curry PARTIAL_TYPES: tuple[type, ...] = (partial, curry) except ImportError: ...
e751bf50118058dee4b4197f41fc4f1a582b932937d0ecfa2484950fa98130f7
Python
3,268
80
# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup -------------------------------------------------------------- # If ex...
b82ab89bd64a5f3b8a54f8ccae2e0967810c75cc0c528749e44b9db412966446
Python
3,269
109
import brainpy as bp import brainpy.math as bm import numpy as np import matplotlib.pyplot as plt from cann import CANN1D import scipy #set default ramndom seed for reproducibility np.random.seed(111) #set backend to cpu bm.set_platform('cpu') #build and run the network cann = CANN1D(tau=3, tau_v=144., num=128, mbar=1...
37206bee923aadc3891e3a3acc42ab2b2865e7c9e53601912a08352b50b13c85
Python
3,270
95
from pathlib import Path import numpy as np import pandas as pd import polars as pl from neuralib.typing import PathLike from rich.pretty import pprint class PickleParquetViewer: def __init__(self, file: PathLike, view_array_shape: bool = False, view_iterable_len: bool = False)...
92fbe2620a9dce3f9f5aad2162997f0f29b9142296a31bd2d41a016e11d3ee9d
Python
3,270
99
#!/usr/bin/env python3 # imports import argparse from ase import Atoms from ase.io import read, write from ase.optimize import * from ase import units from ase.md.velocitydistribution import MaxwellBoltzmannDistribution, ZeroRotation, Stationary from ase.md.langevin import Langevin from ase.io.trajectory import Trajec...
f89738e93765549f2a977497792d7be69d9bd45d1d3436b8ea65b37d05bf198e
Python
3,273
105
#Aidan Fike #July 21, 2019 #File used to create random dihedral angles and random sequences import random import sys import subprocess import os from shutil import copyfile random.seed(a=None) #Conversion between ints and amino acid names (used for random sequence creation) def getNumLetterConv(): return {0: '...
40460af7ac150d3f8ce91f11fcf1b4e52239073faf2c28e6968c46f427e861cd
Python
3,274
96
import copy import pickle import numpy as np import pandas as pd import fire from joblib import Parallel, delayed import sys sys.path.insert(0,'..') import contrasts import nilearn import nilearn.image from nilearn.interfaces.bids import get_bids_files def process_roi(roi, ref_cst, mask, all_betas, nruns, tmaps, re...
831f86a23df373043e97738496be83f92e883496bfbc38ee16afc814dba620ab
Python
3,275
84
import unittest import logging import numpy as np import pandas as pd import diffxpy.api as de class _TestSingleFullRank(unittest.TestCase): def _test_single_full_rank(self): """ Test if de.wald() generates a uniform p-value distribution if it is given data simulated based on the null mo...
99ed29d5f21a9871c200b9c668542057dab7a67e24f2827f34793ee3626d595a
Python
3,275
76
import numpy as np from scipy.stats import spearmanr from brainscore_core.metrics import Score from brainscore_core.supported_data_standards.brainio.assemblies import DataAssembly from brainscore_vision.metrics import Ceiling from brainscore_vision.metrics.rdm.metric import RDM class RSACeiling(Ceiling): """Inte...
b5211645035b99716dd3920db710e4e1a81142c4d2769df79d773095e603166f
Python
3,275
86
import torch from utils import common_functions as c_f from utils.module_with_records_and_reducer import ModuleWithRecordsAndDistance class BaseMiner(ModuleWithRecordsAndDistance): def mine(self, embeddings, labels, ref_emb, ref_labels, species, mnn, setting): raise NotImplementedError def output_as...
e6b93d34da1b9144845a49307f12674f611021a244642fc998e43500fcf82ccb
Python
3,275
94
"""Save the NSD-core ID and OOD test images of each subject. Parameters ---------- data_ood_selection : str If 'fmri', the ID/OD splits are defined based on fMRI responses. If 'dnn', the ID/OD splits are defined based on DNN features. nsd_dir : str Directory of the NSD. project_dir : str Directory of the project f...
df69ada9433d2f0f1700e15dc688de848f8cbb7a8541293ef1c724e5d8194185
Python
3,276
67
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'feed-viewer.ui' # # Created by: PyQt5 UI code generator 5.7 # # WARNING! All changes made in this file will be lost! from PyQt5 import QtCore, QtGui, QtWidgets class Ui_Dialog(object): def setupUi(self, Dialog): Dialog.setObjec...
e16705180c702496b61c037a756a095c347058fc3fa74da7edc405bba1beea9b
Python
3,276
97
import os.path as op import numpy as np import numpy.testing as npt import pytest from bids.layout import BIDSLayout import AFQ.definitions.image as afm from AFQ.definitions.image import * # interprets images from eval # noqa F403 from AFQ.definitions.image import ImageFile, ThresholdedScalarImage from AFQ.definitio...
a6bc1174db6ee89008fc93d7e0de6af85bc543ef837855955ee411ba9d5893ac
Python
3,277
132
"""Example script for running DyNeMo on simulated HMM-MVN data. This script should take less than a couple minutes to run and achieve a dice coefficient of ~0.99. """ print("Importing packages") import os import pickle import numpy as np from osl_dynamics.simulation import HMM_MVN from osl_dynamics.data import Data...
655efb2ae2f5e3cce789d77b109b7d5985eaddfcaa0440219ad11648d53c20b7
Python
3,281
93
# Copyright (C) 2021-2022 Intel Corporation # Copyright (C) CVAT.ai Corporation # # SPDX-License-Identifier: MIT import glob import os.path as osp import shutil from datumaro.components.dataset import Dataset, DatasetItem from datumaro.plugins.data_formats.open_images import OpenImagesPath from datumaro.util.image im...
b6505fb318f2407feb6f73b71db8fa0c30fee695ce9320bec6852356346f04c2
Python
3,281
108
''' O2H ''' import numpy as np import sys def intro(): print(""" SHORT List of potential energy surfaces for O2H: 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 g...
367f42746d16e1151f82cc2c113c008998334203a3d211b0a0a76eee5508d7cf
Python
3,282
110
import tensorflow as tf import numpy as np import sys from tensorflow.examples.tutorials.mnist import input_data def xavier_init(size): in_dim = size[0] xavier_stddev = 1. / tf.sqrt(in_dim / 2.) return tf.random_normal(shape=size, stddev=xavier_stddev) def feedforward_net(D, H, C): X = tf.placeholde...
d3a2a5fb9aa5da178186d78100efdb1151c56d0479f78b65f5cbc63cdeaea58e
Python
3,282
112
# %% from data_loading import load_dataset import torch from deepcardio import Trainer from deepcardio.losses import LpLoss import os from deepcardio.neuralop_core.training import AdamW from deepcardio.neuralop_core.utils import count_model_params from deepcardio.utils import determine_batch_size from torch_geometric...
0f14848b84925f464505135bb83ee6927f2021607137a120f9fe3969aed05471
Python
3,283
100
# /------------------------------------------------------------------------------+ # | 22-AUG-2022 | # | Copyright (c) Bone Imaging Laboratory | # | All rights reserved ...
d3f4cd8f6ff7436deaed34a5c3fd26b5a759ebcefca6102cd30666bf34cbc9f1
Python
3,284
80
import h5py import numpy as np import scipy.io import pickle def assign_data_from_file(var_path: str, filename: str, model_type: str): """ Loads a variable form a file given a particular way of finding variables in the file, defined by model_type. Returns None if the model type is not defined. :pa...
fb1b2e8069fa30c2b20264c303a54e7453a4f5457febefddf74934b601632f8a
Python
3,284
107
''' CH4 ''' import numpy as np import sys def intro(): print(""" SHORT List of potential energy surfaces for CH4: 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 g...
4f204210902ae8752c6443c01e9e0c412cca9f5f9dcd0b894177d2b3f8f3eee5
Python
3,285
99
#!/usr/bin/env python from __future__ import print_function import random from logging import info from keras.models import Model from keras.layers import Input, Embedding, Flatten, Dense from keras.layers import Reshape, Convolution2D, Dropout from ltlib import filelog from ltlib import conlldata from ltlib import...
9be242383f9eb640157ff21e25f51928d9a42d0dd91a20fbc7548374ced36110
Python
3,285
92
from fairseq.models import register_model, register_model_architecture from fairseq.models.transformer import ( TransformerModel, TransformerConfig, TransformerEncoder, TransformerEncoderLayer, ) from dasa_fairseq.modules.multihead_attention_dasa import MultiheadAttentionDASA class TransformerEncoder...
15c8c94352471ee37caf3b8b89bac4e3ab4f8da01a1522a97b968825b9b9650f
Python
3,286
80
import numpy as np import nibabel as nib from nipype.interfaces.base import BaseInterface, BaseInterfaceInputSpec, TraitedSpec, Directory, TraitedSpec from traits.api import Either, File, List, Bool class MergeGiftiInputSpec(BaseInterfaceInputSpec): mesh_gii_file = File(exists=True, mandatory=True, desc='Input GIF...
539955119eb27290973d29c552858aae8da31dc2151f42c48463e6b50a559a92
Python
3,286
79
from pathlib import Path import numpy as np import xarray as xr from brainscore_core.supported_data_standards.brainio.assemblies import PropertyAssembly from brainscore_core.supported_data_standards.brainio.packaging import package_data_assembly import pandas as pd DATASETS = ['short-2', 'short-4', 'short-6', 'short...
023712a811a3376d6d67e92f7c5e818b9117f623b0651ceca51e905ea883ace1
Python
3,287
120
import numpy as np import pytest import ccf_streamlines.coordinates as coordinates def test_mismatch(): test_coords = np.array( [ [0, 0, 0, 0], [1, 1, 1, 1], ] ) resolution = (10, 10, 10) with pytest.raises(ValueError): coordinates.coordinates_to_voxel...
1b5d73ab3ac40e4b718e57890dcf68b7efd029cb6d971c050079e6f1134f17dd
Python
3,287
111
import brainpy as bp import brainpy.math as bm import numpy as np import matplotlib.pyplot as plt from cann import CANN1D import scipy #set default ramndom seed for reproducibility np.random.seed(111) #set backend to cpu bm.set_platform('cpu') #build and run the network cann = CANN1D(tau=1., tau_v=48., num=128, mbar=2...
c3ef84c26d85e3a0d5fde2873884ac52dd2be6e2dc3352637cfe8a794b8297e9
Python
3,287
122
import numpy as np import pytest from lmfit import CompositeModel, Model from impedancefitter.utils import get_equivalent_circuit_model def test_single(): """Test single resistor.""" model1 = "R" model = get_equivalent_circuit_model(model1) assert isinstance(model, Model) def test_single2(): ""...
e5e8870e6280432ae5c77fdd1ac04fb23acfcab1c5273201b7b4d5ea8e487db5
Python
3,288
97
from ..qt import * from ..config import ObservableDict from .. import thalamus_pb2_grpc from ..observable_item_models import FlatObservableCollectionModel, TreeObservableCollectionModel, TreeObservableCollectionDelegate import logging LOGGER = logging.getLogger(__name__) class Run2Widget(QTabWidget): def __init__(...
1ebde8783ddf61f3307271158a4fbedb2358c82cdff554bea15730ec3fc903c8
Python
3,290
102
""" This module contains the functions to adapt the simulated reflectance spectra to the TIVITA camera wavelengths. """ import os import numpy as np import pandas as pd from dotenv import load_dotenv from mcmlnet.susi.adapt_to_camera import adapt_to_camera from mcmlnet.utils.logging import setup_logging load_doten...