sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
68fa2d9dc0e96723c9e148078787f66897d5047677b669896e5e204cc4b8aa67
Python
8,664
186
import random import torch import os import argparse import torch.nn.functional as F import numpy as np import pandas as pd from torch_geometric.data import Batch,Data from dataset.large_dataset import Cath from run_pt import Trianer,EGNN_NET,Sparse_DIGRESS amino_acids_type = ['A', 'R', 'N', 'D', 'C', 'Q', 'E', 'G', '...
0493a59cafecdc31cc0ba05a0c0eb9ed7a9b783411a59a1c6a21d38a33fe3dba
Python
8,665
197
import tensorflow as tf class TGCNN_layer(tf.keras.layers.Layer): """Applying a filter to a single graph over time slices Args: input_graphs: 4D tensor of sparse graphs (batch_size, num_nodes, num_nodes, timesteps) num_filter: number of graph filters/features to use fi...
b66b6acb4dc2bdb416ddc26d97b8f616773242ce311944ed39e8d861181694fc
Python
8,665
217
from collections import OrderedDict # pylint: disable=g-importing-member import torch import torch.nn as nn import torch.nn.functional as F import functools from brainscore_vision.model_helpers.activations.pytorch import load_preprocess_images from brainscore_vision.model_helpers.activations.pytorch import PytorchWrap...
d938a8c8f42b54b9beaea60d280bf723a426c9d876a4d32df4326b7d0ff95876
Python
8,665
229
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 SeparableConv3d(nn.Module): def __init__(self,in_channels,out_channels,kernel_size=1,stride=1,padding=0,dilation=1,bias=False): super(SeparableConv2d,self).__init_...
cf082f53e133e2f77a8730ab191ccb4fb12c1d7b1723f93728fa58d065dff9ff
Python
8,666
247
#!/usr/bin/env python # src/tuning/optuna_regression.py """ Optuna TPE 超参数优化 — 回归模型 --------------------------------- 功能: 1. 定义超参数搜索空间:包括隐藏层宽度、dropout、学习率、batch_size 等。 2. 在每次 trial 中,将采样到的超参数写回到 C.HIDDEN_SIZES、C.DROPOUT,然后实例化 RegressionModel。 3. 在第一折数据上训练若干 epoch,在验证集上以 RMSE 最小化为优化目标。 4. 完成所有 trial 后,将最优超参数保存到 resul...
d62c69b56659d1a696cb798beab1729b1f825c409e32c860b2e9011d13703207
Python
8,666
269
from collections.abc import Sequence from functools import partial from pathlib import Path from docs.doc_modules.experiments import AutoDocExperimentInfo, run_capture_and_save from docs.doc_modules.serve_experiments_utils import load_data_for_serve from docs.doc_modules.serving_experiments import ( AutoDocServing...
0a8b6ff575f628838063d58b9e1020aa25b0b6f6c675b83a404edea70ed9fb23
Python
8,667
218
from collections import OrderedDict # pylint: disable=g-importing-member import torch import torch.nn as nn import torch.nn.functional as F import functools from brainscore_vision.model_helpers.activations.pytorch import load_preprocess_images from brainscore_vision.model_helpers.activations.pytorch import PytorchWrap...
51ab0d5f07691b0a3e69ea6800f06a750adb7eb179af5349ee651a7586df802d
Python
8,667
263
#!/usr/bin/python3.8+ # -*- coding: utf-8 -*- # @Time : 2022/2/26 21:53 # @Author : Z.-H. G. # @Email_0 : guozhenhao17@mails.ucas.ac.cn # @Email_1 : guozhenhao@tongji.edu.cn # @File : script.py # @IDE: PyCharm import numpy as np import torch import torch.nn.functional as F from sklearn.preprocessing import Stan...
2bab6fee245bf2b66c7603f044ee494980d0e8ee826ea2eb3953b289f10240af
Python
8,668
212
"""Discrimination, calibration, and operational metrics. Operational metrics (false alarms per hour, warning lead time) are computed from an alarm *policy*, not from raw per-window thresholding: a deployed system debounces. Reporting per-window false positives as an alarm rate overstates nuisance alarms by roughly the...
7946e63b08f3fbef86b501b2a94ed00f15a5214142e71426e1e3b4924066ce6f
Python
8,668
171
from scipy.misc import imsave, imresize import matplotlib.pyplot as plt import tensorflow as tf import PIL.Image import numpy as np import shutil import time import os import cv2 import keras paths = { 'Data': 'ILSVRC2012_img_val', 'Label': 'val.txt' } for key in paths: assert os.path.exists(paths[key]...
e1f65d885578cfc11b20818c31a13d3c446b33d97959fc2e344feb58adbdd238
Python
8,670
221
import scipy.optimize import numpy as np from .cost import get_cost from ..base import Backend, FitResults class SciPyBackend(Backend): """Default backend: just passthrough NEMS model methods except fit.""" def _build(self, data=None, eval_kwargs=None, **backend_options): """Duplicate reference to `S...
d95bf8333f47784be475ade00928076c73f2102c6d87bd03ea554a4e94bba960
Python
8,671
263
from pathlib import Path from unittest.mock import Mock, create_autospec, patch import pytest import torch from fastapi import HTTPException from eir.serve_modules.serve_input_setup import ( ServeBatch, _check_prompt_fits_output_length, _impute_missing_tabular_values, _setup_tabular_input_for_serve, ...
e8123cd0183a46b56d1c11b78792cdaf8715039a44f1b3f1a8faed514b58f97c
Python
8,672
204
import sys sys.path.append('../..') from PAINTeR import connectivity # in-house lib used for the RPN-signature from PAINTeR import plot # in-house lib used for the RPN-signature from PAINTeR import model # in-house lib used for the RPN-signature import numpy as np # hi old friend import pandas as pd from sklearn.prepr...
02f6db4deeef991d832f661d3dc55502c7a6445b65c488fb58b3477fe6be2dcb
Python
8,673
259
""" Tests functionality of the H5FileLoader """ import os from test.unit.util import is_equal_np from typing import List import h5py import numpy as np import pytest from deepreg.dataset.loader.h5_loader import H5FileLoader def get_loader_h5_file_names(loader: H5FileLoader) -> List[str]: return [f.filename for ...
d87f86fe0d957b68681d1b6a79c942840a3485d3dabe5126126abd6f4ec22bbf
Python
8,674
216
"""The per-recording activity raster for CAT-NAP — plain and z-scored. ``MEApipeline.m`` draws a ``3_Raster`` for every suite2p recording: the activity matrix the network was built from, cells down the side and time along the bottom (``rasterPlot.m`` with ``get2pActivityMatrix``). The Python port had no equivalent — a...
e0b1ac1d6b035d230db00e6116e100ef225f349598a01c4f6b952aff2c4523e2
Python
8,676
183
import pandas as pd import shutil, os import os.path as osp from ogb.utils.url import decide_download, download_url, extract_zip from ogb.io.read_graph_raw import read_csv_graph_raw, read_csv_heterograph_raw,\ read_node_label_hetero, read_nodesplitidx_split_hetero,\ ...
5621f5c04ec36b1eab5c6261ace8c0f7bf672aeb7361575f0fdf3f74df7bf52c
Python
8,681
202
# /------------------------------------------------------------------------------+ # | 19-JUL-2022 | # | Copyright (c) Bone Imaging Laboratory | # | All rights reserved ...
cc08b0f28a85c9e2f039a411127598a026eac3ad47ef513bd716222ad02bb089
Python
8,681
206
#!/usr/bin/env python3 import importlib from nipype.interfaces.fsl import Reorient2Std import PUMI from PUMI.engine import BidsPipeline, NestedNode as Node, FuncPipeline, GroupPipeline, BidsApp from PUMI.pipelines.anat.anat_proc import anat_proc from PUMI.pipelines.func.compcor import anat_noise_roi, compcor from PUM...
7af31b68688cf7e39ea358bdb748c9cf0df470943b0af7c27cd6ff62e9f39c48
Python
8,682
291
# The ImpedanceFitter is a package to fit impedance spectra to # equivalent-circuit models using open-source software. # # Copyright (C) 2021 Julius Zimmermann, # julius.zimmermann[AT]uni-rostock.de # # This program is free software: you can redistribute it and/or modify # ...
b761a0bb8220bb5d288a1dc61f1d6011bdbe6b55070e8b244ab9ad9d08c532c7
Python
8,683
239
import os from Bio import SeqIO import pandas as pd import sys sys.path.append('../bin') from ngs_split_reads import split_reads from ngs_combine_read_cnt_map import combine_read_cnt_and_map from ngs_count_barcodes import count_barcodes def test_split_reads_uneven_chunks(tmp_path): infile = "data/ngs/barcodes_co...
c3b2191ec2a26f44492b858d0e6c58ad5d194db36a6876d7ae84a29af76e7753
Python
8,685
258
# -*- coding: utf-8 -*- """ PSF estimation of multipolar phase-encoded paradigm. The data is fitted by either a Gaussian function or an exponential decay function using the ODR method. Uncertainties of fit parameters are the standard method using diagonal elements of the covariance matrix. """ # python standard libr...
679b874deddcd25579647e40a14b90b7126439e524366b9fec7c98cfcad823ec
Python
8,686
203
import torch import torch.nn as nn from typing import List import math class Rotate3DBatch_UnifDist(nn.Module): """ Rotate the input 3D tensor around the x-, y- and z-axis. This class is designed to be used with the GPU with batch processing. """ def __init__(self, range_x: List[float], range_y: List...
3871abd56110b601e30d2d50c26aec2e7475ace3e9764a4740abbb0431a5d012
Python
8,689
253
""" Sei architecture """ import numpy as np import torch import torch.nn as nn import numpy as np from scipy.interpolate import splev def bs(x, df=None, knots=None, degree=3, intercept=False): """ df : int The number of degrees of freedom to use for this spline. The return value will have t...
c03ed9b85097eb6dcc6eeb1aa3303ccd79c036090d8e88df3863d9c05cbf54c0
Python
8,691
228
import os import numpy as np import librosa from glob import glob import torchaudio import math import torchaudio.functional as F #import disvoice SAMPLE_RATE= 16000 from scipy import stats from disvoice.prosody import Prosody import parselmouth F0_FORMANT_COUNT = 4 # F1~F4 def get_formants(filena...
bf1da8e23ae5fd90dec5477565cdd383b312b70c8be41b1974e3461646b076bd
Python
8,692
312
# FetMRQC: Quality control for fetal brain MRI # # Copyright 2023 Medical Image Analysis Laboratory (MIAL) # # # 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/lice...
24c1a29c90e400486b8fb1cf4e70dd01305de280c7d569bdc82020794ecd6a47
Python
8,693
224
import sys import yaml import os from glob import glob import numpy as np import h5py import matplotlib.pyplot as plt import matplotlib as mpl pathpath,myrun = sys.argv[1:] ''' pathpath = 'PATHS/filepaths_carlen.yml' myrun = 'runC00dMP3_brain' ''' with open(pathpath) as yfile: pathdict = yaml.safe_load(yfile) rundi...
a3c34cff179a92d8b8ff36138068a021fc8cc8919043a6c78f0baf73bab4f2c9
Python
8,698
237
# -*- coding: utf-8 -*- """ Created on Wed Jan 13 13:57:54 2016 @author: ajaver """ import json import os import subprocess as sp import warnings from collections import OrderedDict import numpy as np import tables from tierpsy.helper.misc import TimeCounter, print_flush, ReadEnqueue, FFPROBE_CMD def dict2recarray...
a87dc34af9cb82765a05395b53cfd8b4f647658eeb94a0a18f9267912bdfb86e
Python
8,698
282
from __future__ import annotations from pathlib import Path from typing import Final import numpy as np import pytest from PySide6.QtCore import QPoint from PySide6.QtCore import QPointF from PySide6.QtCore import QRect from PySide6.QtCore import Qt from PySide6.QtGui import QColor from PySide6.QtGui import QImage fr...
6986714f210648613e146c1421c2f85da9660cc1719521fc6935aba8edc86c70
Python
8,703
227
import click as ck import pandas as pd import torch as th import numpy as np from torch import nn from torch.nn import functional as F from torch import optim from torch.optim.lr_scheduler import MultiStepLR from sklearn.metrics import roc_curve, auc, matthews_corrcoef import copy from torch.utils.data import DataLoade...
3bd8b5be0a5e93a849f8814c70aabe6c605e33067acbb54be6f6eda7684d3fdc
Python
8,704
290
import math from typing import Literal import torch from torch import nn from eir.models.fusion.seq_out_fusion_attention import CrossAttention from eir.models.layers.attention_layers import SwiGLU from eir.models.layers.cnn_layers import adjust_num_heads from eir.models.layers.norm_layers import LayerScale from eir.m...
7a1b6fada43e18196d08d6586568c26766e4ae64979bde599f8f29c0850b60a3
Python
8,707
185
# Copyright (c) 2026 Rohit Jena. All rights reserved. # # This file is part of FireANTs, distributed under the terms of # the FireANTs License version 1.0. A copy of the license can be found # in the LICENSE file at the root of this repository. # # IMPORTANT: This code is part of FireANTs and its use, reproduction, or ...
0d207103f1c579f166beed88bd377430f2c76654b35ea5bf8c99259b68af2958
Python
8,709
192
import os import scanreader import numpy as np import datajoint as dj from commons import lab from pipeline.exceptions import PipelineException from pipeline import reso, experiment, mice, notify, shared from pipeline.utils import galvo_corrections, signal, quality, mask_classification, performance, h5 # external stor...
2d4131395fb1e06140747bb8b5a7b186a6f089193260d38fe7c5892d3016d664
Python
8,709
287
from functools import partial from numbers import Number from typing import List, Tuple, Optional import bism.backends import bism.modules import torch import torch.nn as nn from bism.models.spatial_embedding import SpatialEmbedding from torch import Tensor from yacs.config import CfgNode def cfg_to_bism_model(cfg: ...
4ec5868eafa18f04f43312eb2f27608bb15ead819c185dc33b9eb63ab6565bfc
Python
8,711
244
from pathlib import Path import numpy as np from functools import cached_property from matplotlib.axes import Axes from typing import Literal from argclz import AbstractParser, as_argument, argument from neuralib.persistence import persistence from neuralib.plot import plot_figure from neuralib.plot.tools import Axes...
aaea878548a845de7dddfaa73da46fb9210f9ecc3db7d257344f09c6ec19c61a
Python
8,712
187
# Copyright (c) 2026 Rohit Jena. All rights reserved. # # This file is part of FireANTs, distributed under the terms of # the FireANTs License version 1.0. A copy of the license can be found # in the LICENSE file at the root of this repository. # # IMPORTANT: This code is part of FireANTs and its use, reproduction, or...
013791af3c7cb8429c690bc4b551659a61dadc4423507ea0ab8783f1539f37e1
Python
8,713
171
"""Build the Li2026 (Triple-N) static neural assembly and stimulus mapping from the raw ScienceDB release. Run this before :mod:`package_li2026` (which uploads the outputs to S3). Raw source -- Triple-N, ScienceDB doi:10.57760/sciencedb.33556:: <raw-root>/Processed/Processed_ses*.mat per-session trial-averaged re...
6560c23af9cd482febe693bb52c1fa22f13d91b1b64809434d7bd1dd02c4813f
Python
8,713
224
''' 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 ''' from sklearn.utils import shuffle import numpy as np import h5py from functools import partial from chinn.common import check_chrom, chrom_to_int from chinn.pair_...
076ed1ba7bf02e4f88a54b38b6cca7f554dcb5d4032d44acd306bf2e75e2e268
Python
8,716
215
import os import matplotlib import torch import torch.nn.functional as F matplotlib.use('Agg') from matplotlib import pyplot as plt import scipy.signal import cv2 import shutil import numpy as np from PIL import Image from tqdm import tqdm from torch.utils.tensorboard import SummaryWriter from .utils import cvtColo...
9707b07b209c45ce8038d7b91c33942d2195d54700ce5b218529c697246509f8
Python
8,716
276
#!/usr/bin/env python # # A script to submit jobs to the SLURM queuing system # # F. Nedelec, 10.2007 --- 29.09.2018 # Adapted from LSF to SLURM on 17.02.2017 """ Submit an array of jobs to the SLURM system, to be handled by 'go_sim.py' Syntax: submit.py ARG [mem=????] [queue=????] [hours=INT] [days=...
3099d0ea29003208ce228fa3ab90b4f1ccafadeb87578bdfd774fb9eff3a5a37
Python
8,719
245
import json import argparse from chemgraph.tools.ase_tools import run_ase from chemgraph.tools.cheminformatics_tools import molecule_name_to_smiles, smiles_to_atomsdata from chemgraph.models.ase_input import ASEInputSchema import datetime import subprocess def get_smiles_from_molecule_name(name: str) -> dict: """...
741ff1e7ff2974cf1da69a0be1aa888833cb1e84919ad2ba7c4566e5c3c56501
Python
8,719
76
from testsetclass import TestsetClass class S66(TestsetClass): def __init__(self): self.weak = 1.0 self.molecules = ['36B', '61', '39A', '59', '66', '16A', '50', '19B', '50B', '57', '03', '13B', '04', '55A', '32', '33A', '35', '56', '35B', '51', '58', '53B', '15A', '60', '34', '56A', '33', '59B', ...
8615f495aff3752ff39a4aa396e129e6c374b6b8f31d7c07b87edf18dd764e77
Python
8,721
206
from __future__ import annotations from torch.utils.data import Dataset from typing import TYPE_CHECKING if TYPE_CHECKING: import seisbench.data as sbd import pandas as pd class GenericGenerator(Dataset): """ A generic data generator which can be used to build preprocessing and data augmentation pip...
af0daa92b5ee14cff4d931a2e7f45524d6dc7e25bab83023f936a6ee8a5b7c43
Python
8,722
245
import json import argparse from chemgraph.tools.ase_tools import run_ase from chemgraph.tools.cheminformatics_tools import molecule_name_to_smiles, smiles_to_atomsdata from chemgraph.models.ase_input import ASEInputSchema import datetime import subprocess def get_smiles_from_molecule_name(name: str) -> dict: """...
e927824197a66856218d8655e14ba8b3eff83ec1e8f7508436dba54cbd07c259
Python
8,722
237
'''MobileNetV3 in PyTorch. See the paper "Inverted Residuals and Linear Bottlenecks: Mobile Networks for Classification, Detection and Segmentation" for more details. ''' import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import init class hswish(nn.Module): def forward(self, x): ...
ae86b287b4c85f76336ae2a3a96a842cccda6051243232a8417e3c8a380e410f
Python
8,724
225
import numpy as np import polars as pl from tqdm import tqdm from typing import Literal from argclz import AbstractParser, argument from neuralib.io import csv_header from neuralib.plot import dotplot from neuralib.plot import plot_figure from neuralib.suite2p import get_neuron_signal, sync_s2p_rigevent from neuralib....
47d9a45d11a72dfe954579cd94ce64b9a9d8ae903da269b73fe5035d900c698d
Python
8,725
227
# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp import tempfile import warnings import mmcv import numpy as np import torch from mmcv.engine import collect_results_cpu, collect_results_gpu from mmcv.image import tensor2imgs from mmcv.runner import get_dist_info def np2tmp(array, temp_file_name=N...
cdaca23fbfba3c84e7dca6c8f36633a9750a8848987528a278c15961be1e41ec
Python
8,725
213
# -*- coding: utf-8 -*- """ Created on Wed May 13 19:35:04 2015 @author: ajaver """ import os import sys import numpy as np import pandas as pd import tables from tierpsy.helper.params import head_tail_defaults from tierpsy.analysis.ske_orient.WormClass import WormClass from tierpsy.helper.misc import TimeCounter, ...
8e3bed0401aeb4ebc0901b0e64a5d9d72df074a54d99a1da907b69c103417e70
Python
8,726
185
"""``meanap-stats`` — run the statistics and machine-learning step from a shell. The step reads a finished run, so it is useful on its own: a run analysed months ago, or one someone sent as a bundle, can be put through it without re-running the pipeline. """ from __future__ import annotations import argparse import ...
ae637d5aa8b6a6e843497957de73741f8fd4d0a913cc00335ee3d8c55a74d73b
Python
8,728
123
from brainvoice.data.estimates_loader_utils import load_beta_estimates, load_estimate_labels from joblib import load from tqdm import tqdm import os import numpy as np import glob2 import pandas as pd import argparse from sklearn.metrics import balanced_accuracy_score import collections """ python src/...
3ad44c37c66613326bcc40116e58d684fac56f0438f31c48369f819be4827daa
Python
8,729
289
""" Functions to read and write dMRI image data and parameter files. """ import numpy as np import numpy.typing as npt import nibabel as nib def data_from_file(im_file: str, bval_file: str, bvec_file: str | None = None, cval_file: str | None = None, roi_file: str | None = None) -> ( tuple[npt.NDArray[np.float...
02d701b18db2806e71f3dd04f1e0d5f4432b1358fdebfeca2ed6b637f9088e25
Python
8,732
217
""" This class handles the overlay of highlights and the brain area name in the status bar. This enables more than one plugin to use these features. """ import numpy as np import pyqtgraph as pg # For contour drawing from skimage import measure from lasagna.tree import tree_parser # For handling the labels files fr...
9db022a01176559c999cfed07e1ddf7b9f5961f9cf6383bbaedfcd59f6347797
Python
8,733
167
from curses import meta import os import pickle import random import numpy as np import pandas as pd from tqdm import tqdm from glob import glob import torch from torch.utils.data import Dataset from copy import deepcopy import torchaudio from .psy_util import generate_fbank, get_individual_samples_torcha...
f336557bd2a9de5b2e9820e8a9be48d3b9e07bf56ace3e2f4e1d75834648210d
Python
8,734
197
# Copyright (c) 2026 Rohit Jena. All rights reserved. # # This file is part of FireANTs, distributed under the terms of # the FireANTs License version 1.0. A copy of the license can be found # in the LICENSE file at the root of this repository. # # IMPORTANT: This code is part of FireANTs and its use, reproduction, or...
567a4390fc1841241f6fe760252cafc1e5aeb3a99a36676eca47aebc389420c0
Python
8,735
218
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Register DWI to a template for screenshots. The templates are on http://www.bic.mni.mcgill.ca/ServicesAtlases/ICBM152NLin2009 For quick quality control, the MNI template can be downsampled to 2mm iso. Axial, coronal and sagittal slices are captured. """ # noqa import...
42c79e68e3e13115fa7df6db4a4fd381414abafdd65fabe93369e539b1ad55ce
Python
8,737
217
from __future__ import print_function, absolute_import import argparse import os.path as osp import random import numpy as np import sys import os import torch from torch import nn from torch.backends import cudnn from torch.utils.data import DataLoader import torch.nn.functional as F print('We are here: ', os.getcwd()...
4c32453c3ea6f913fabfa6236e8926301b612d5f957a3197e73bbd765578f795
Python
8,738
280
from collections.abc import Callable, Sequence from copy import deepcopy from dataclasses import dataclass from pathlib import Path from typing import TYPE_CHECKING, Any, Union import torch from fastapi import HTTPException from torch.utils.data._utils.collate import default_collate from eir.data_load.data_preparatio...
d81bc82e293c13d19db7839262a50f84706a2f295d9ba83353c7203b1413f366
Python
8,738
217
import numpy as np import numpy.typing as npt def seg(Y, b, bthr = 200, verbose = False): """ Segmented fitting of the IVIM model. Arguments: Y: v x b matrix with data b: vector of size b with b-values bthr: (optional) threshold b-value from which signal is in...
df68ab1e1ca0ff3c404da628f39199a3b09fc1df95ae258000d6e1f1c4475200
Python
8,739
225
"""Feature extraction and windowing for the Cao et al. (2019) corpus. Emits the same dict structure as the UL-DD and DD-Database paths, so the nested leave-one-subject-out harness, bootstrap and paired tests are shared unchanged. **Scope.** This corpus carries EEG only -- no ECG and no dedicated EOG. The two-branch f...
60ae61ae7ce2ac0e8432e97464921b3dafeabd9136d770410fc3b2a1f7a10d1d
Python
8,741
254
from subprocess import PIPE import unittest import numpy as np class TestFileIO(unittest.TestCase): def test_feed_pipe(self): from python.segmentation.FileIO import feedPipe from unittest.mock import Mock import numpy as np mockPipe = Mock() # Mock stdin/stdout/stderr ...
6961f2b6b336501ecaed497b5642e2626d60a81e6b861455822678df256f3664
Python
8,741
226
# -*- coding: utf-8 -*- # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import numpy as np import torch from torch import nn from typing import Any, Optional, Tuple, Typ...
a592513e7fb0f6ed308ab036a961fe99382d3b09bd1fe3a503d5d8e65ff2e936
Python
8,741
239
import torch from torch_geometric.nn import MessagePassing import torch.nn.functional as F from torch_geometric.nn import global_mean_pool, global_add_pool from ogb.graphproppred.mol_encoder import AtomEncoder,BondEncoder from torch_geometric.utils import degree import math ### GIN convolution along the graph structu...
d6000bf979ee2fe4872bd8508e1c8b9c89b39dc017062263043b6502eb4f299e
Python
8,742
213
"""Test what CAT-NAP does with a suite2p folder whose files contradict itself. Run from the repo root:: uv run python python/test_catnap_roi_mismatch.py The case this is built from is real. In ``OPME240520_17_20240602_P1_pup2D_Het_MOI50000_DIV13`` of a 382-recording share link, ``iscell.npy`` holds 5040 rows whi...
504b0a78018e0c573ae9036eb08a6d681d60bbb986a089718202fa1c788f3e62
Python
8,743
233
import numpy as np from scipy.spatial import ConvexHull from matplotlib.path import Path from scipy.spatial.distance import cdist import networkx as nx import pandas as pd import matplotlib.pyplot as plt from .helper import intersect, to_dense_array, extract_data_matrix, glmpca_distance from .PASTE2 import partial_pai...
25d1a4d87a5d18bd88bf37bc50f6c1f9285d4903cdfa8d1e1263a187c603800c
Python
8,746
285
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved import logging import math import os import random import re from datetime import timedelta from typing import Optional import hydra import numpy as np import omegaconf import torch import torch.distributed as dist from iopath.common.file_io im...
71cf9400aa5e5ef1e6a84b77a6ad45d450931231d60482d6ba9bd3f0606f9290
Python
8,746
207
#!/usr/bin/env python3 import os import inspect import unittest import logging import shutil import bt2face import dataface import btdata from optparse import OptionParser class TestRegressions(unittest.TestCase): """ Main regression fixture. """ def test_288(self): """ Check if --un opt...
9ded6d9f9a149821637d73b54e352a75b411b05f1608e030d50272146d452170
Python
8,747
208
""" In case you have extracted events that are too short, this script will extend them by the needed amount of frames """ #%% from pathlib import Path from benedict import benedict import tifffile import napari import matplotlib.pyplot as plt import numpy as np from ome_zarr.reader import Reader from ome_zarr.io impo...
f8c392800b434f95bbdaf80c69048a543dc2fd1cf842f1b61077e6d446851138
Python
8,747
239
# -*- coding: utf-8 -*- # @Author : LG import os from xml.etree import ElementTree as ET import cv2 import imgviz import numpy as np import yaml from PIL import Image from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5.QtCore import QThread, pyqtSignal from ISAT.annotation import Annotation, Object from ISAT.conf...
029dac745b1a8eeae525bb3060869f6048dbddccbf2b7602fafaabcdb6673340
Python
8,748
219
import os import logging import numpy as np from tqdm.auto import tqdm from collections import OrderedDict from typing import Any, Callable, Dict, Hashable, List from ..inputs import Stimulus from brainscore_vision.model_helpers.utils import fullname from joblib import Parallel, delayed # a utility to apply a list ...
4ceb6702beef46c832dfdacf57623e49b259b2057094199e27d87dd22ffbf6c7
Python
8,750
237
import torch.nn as nn import math import torch.utils.model_zoo as model_zoo import torch import torch.nn.functional as F __all__ = ['Res2Net', 'res2net50'] model_urls = { 'res2net50_26w_4s': 'https://shanghuagao.oss-cn-beijing.aliyuncs.com/res2net/res2net50_26w_4s-06e79181.pth', 'res2net50_48w_2s': 'https://...
2869a0e5c47ac5806050a326dd56ce14ddbecdd0c0d83dbf67cccc528de7046b
Python
8,751
243
import argparse import torch import numpy as np import torch.nn.functional as F from torch.utils.data import DataLoader from torch_sparse import SparseTensor from torch_geometric.data import ClusterData, ClusterLoader from torch_geometric.nn import GCNConv from torch_geometric.utils import to_undirected from ogb.lin...
5b0a736ff3c9ee03c4fe53b9dfc6a7fa5f65a5afa260177ed0f4836cfc6f4621
Python
8,752
5
standard_train_fold=['202990', '116221', '110003', '265302', '33089', '286943', '122439', '126872', '43371', '81406', '246216', '41381', '118639', '121759', '193894', '106077', '193291', '100367', '79356', '241172', '112604', '202431', '127470', '241178', '193093', '52067', '112172', '264418', '238060', '238063', '2140...
643683a645028e60884ea663c5f891b40469d769b15b436996c0f5e96d98676d
Python
8,752
239
import torch from torch_geometric.nn import MessagePassing import torch.nn.functional as F from torch_geometric.nn import global_mean_pool, global_add_pool from torch_geometric.utils import degree import math ### GIN convolution along the graph structure class GINConv(MessagePassing): def __init__(self, emb_dim):...
ab5470252950e44fdf2023eff8517c242d4c74c29a13b4d3f774e46a89b65a6f
Python
8,753
232
# ===================================================================== # Title: engine.py # Description: This file contains the engine class that handles the # optimization of temporal mapping of SALSA. # # Date: 02.01.2023 # # =================================================================...
e2961557ec5c2184a69b36a85dbb46562bc77d3b7286b9f6f0147c615a7a5e6f
Python
8,754
198
#!/usr/bin/env python """ This class provides software emulation of a camera for testing purposes. Hazen 02/17 """ import ctypes import numpy import random import time from PyQt5 import QtCore import storm_control.sc_library.parameters as params import storm_control.hal4000.camera.cameraControl as came...
a69dbf1108df7d43eefebc878cf0c7db320e3191fcad1cccc121f0521d297789
Python
8,756
222
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Take screenshot(s) of one or more slices in a given image volume along the requested axis. If slice indices are not provided, all slices in the volume are used. The name of the output images are suffixed with _slice_{id}, with id being the slice number in the volume. I...
21d3bb667ca6420bd649bd70a32145cb32b0c1c0c7dc6c6dae8dad24b42b8690
Python
8,757
267
from __future__ import annotations from typing import Tuple import numpy as np import networkx as nx # (still unused here, but kept in case other code relies on it) from typing import List, Optional, Tuple from .config import LaminarConfig from .io_utils import group_files_by_layer, load_and_concat_layer def thres...
23b42d51a81dc0d0ee655fef0478a79257618078ba88d9787b16181cca45ea51
Python
8,759
149
from typing import Optional from pytorch_lightning import LightningDataModule from torch.utils.data import DataLoader from project.datasets.CASP_CAPRI.casp_capri_dgl_dataset import CASPCAPRIDGLDataset from project.datasets.DB5.db5_dgl_dataset import DB5DGLDataset from project.datasets.DIPS.dips_dgl_dataset import DIP...
2865fec361c576d33988a984f8e5f6f8970970fb490ed408bb02f41cfc4503b9
Python
8,760
260
from rdkit.Chem import Draw from rdkit import Chem from rdkit.Chem import rdFingerprintGenerator from src.convert_spectrum_to_colour import * from typing import Tuple, List import numpy as np from rdkit.Chem.Draw import rdMolDraw2D from PIL import Image import io, base64, os def wavelength2float(wstring: str) -> floa...
397f8f7b331a4eec8d7d472853b01ff45b6eb2cec70f068bb20f1c40e39bc845
Python
8,762
258
from annotate import main as annotate from optimize_FLAMES import main as optimize from FLAMES_scoring import main as FLAMES_scoring import os import sys import argparse import pandas as pd def splash_screen(): print('\n*********************************************************************') print('*Fine-mapped...
58967240c05c55b50adfd59120071cb62cef3f3c5f52106fdaf21c9f023467f3
Python
8,762
193
try: import PyQt6 HAS_QT6 = True except ImportError: HAS_QT6 = False if HAS_QT6: from PyQt6.QtGui import (QTransform, QPolygon, QOpenGLContext, QPainter, QImage, QMouseEvent, QColor, QFont, QContextMenuEvent, QAction, QPixmap, QPainterPath, QBrush, QKeyEvent, QStandardItemModel, ...
838e7a43ba9db07238285344de5da51aefc884574081d70c102304fe4005ca7d
Python
8,763
192
# Author: Francois Aguet import numpy as np import scipy.stats import pandas as pd import argparse import pyBigWig import os import subprocess import io import gzip import pickle import qtl.stats parser = argparse.ArgumentParser(description='ASE') parser.add_argument('read_count_file_list', help='Read count file list...
0bd713efeadc58f8271baf046ffb80727f741d2dcebce1ba9f87d8de28691612
Python
8,764
217
import inspect from collections.abc import Sequence from typing import Any, List, Optional, Type, Union import numpy as np import torch from torch import Tensor from typing_extensions import Self from torch_geometric.data.collate import collate from torch_geometric.data.data import BaseData, Data from torch_geometric...
e4093fc0d811cd67a91c18d731dfb7b560d6c70f3c4921254179681222c89442
Python
8,764
186
"""Record normalization and deterministic gRASPA analysis shared by clients and MCP.""" from collections import defaultdict import csv import json import math from pathlib import Path, PureWindowsPath import uuid from chemgraph.schemas.graspa_analysis import GraspaAnalysis def write_json(path: Path, value) -> None:...
bce247ea14ca7e3934369993a8d299e8ef9afeb273463c3759bce92f2b767381
Python
8,766
192
import pytest pytest.importorskip("fireants_fused_ops") import torch from time import time from fireants.losses.cc import LocalNormalizedCrossCorrelationLoss from fireants.tests.cc_mem_test import fast_lncc from fireants.losses.fusedcc import FusedLocalNormalizedCrossCorrelationLoss seed = 4531 torch.manual_seed(seed)...
7000f4fc6ffaf59ba2c79de8736c5ac332b893a64f5ff1740f20450651b9d71b
Python
8,768
285
"""Brain-Score wrapper for DeepEISNN EI-SNN ImageNet ResNet18.""" from __future__ import annotations import functools import json import sys from collections import OrderedDict from pathlib import Path from typing import Any, Iterable import numpy as np if not hasattr(np, "int"): np.int = np.int32 import torch...
15c0a6eac2edacd053c30c9953668bd17c4016a188c07835078c595e39b9f589
Python
8,770
236
# %% from pathlib import Path import gc import warnings from tqdm.auto import tqdm import numpy as np import mne import pickle from methods_complexity import get_invalid_epochs, compute_complexity # %% # ======================================================================================= # =====================...
78847e071eddf0f19c9b5c7d6e231ccb2325efcabb4bfb860138857b256f964a
Python
8,771
232
#!/usr/bin/env python3 -u # 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. import torch from pathlib import Path from esm import Alphabet, FastaBatchedDataset, ProteinBertModel, pretrained im...
5b64f0837bfb2badc6ce6b7f6debcaea3a814a7822e7ab7158c086e36b5ae7c8
Python
8,772
237
""" 1. find peaks that higher than 30 % of the highest peak in trial average signal 2. peak activity is at least three times higher than median activity 3. reliability > 20% of total trials 4. exclude peak around reward location (< ?? cm, > ?? cm on the track) 5. different between identified positions is similar to dis...
20f93ae3be3e1a308c0f8a917b43a2641d5aad746a0188f3fef3e4e8ad4962bf
Python
8,774
269
import os import re import shutil from test.unit.util import is_equal_np from typing import Tuple import nibabel as nib import numpy as np import pytest import tensorflow as tf from deepreg.dataset.loader.interface import DataLoader from deepreg.dataset.loader.nifti_loader import load_nifti_file from deepreg.train im...
32b6ae6570865a470bf7a41f8638543fbe244e994a0a2379f176d0698425f55d
Python
8,774
281
#!/usr/bin/env python """ Prior XY stage communication (mostly). Hazen 5/11 """ import time import traceback import storm_control.sc_hardware.serial.RS232 as RS232 class Prior(RS232.RS232): """ Control of a XY Prior stage, possibly with piezo Z control & a filter wheel. Communication v...
5b67590f8b32c999cb5c7ab2e724967bff6c4ce55f8ace134d4ca2b802b9dc6a
Python
8,774
236
import abc import unittest import numpy as np import pandas as pd from sklearn.linear_model import LogisticRegression, LinearRegression from causallib.estimation import IPW, StratifiedStandardization from causallib.metrics import get_scorer, get_scorer_names import sklearn LR_NO_PENALTY = None if sklearn.__version_...
639d5fea2eeb48362ca83b0148ba313bfc66a7be6feda63a4dc8b88dfbaf472c
Python
8,774
258
from typing import List, Final import torch from mlcg.nn import MLP from mlcg.geometry import compute_distances from .base import RANGE from ..blocks import ( RANGEInteractionBlock, AggregationBlock, BroadcastBlock, SchnetBlock, ) from ..system import System from ...utils import create_instance cla...
abfde10a70eec9a8f621909ec9fac37463efceb7bd5b5dbdb5eff37d6fcf4b63
Python
8,776
211
""" HierarchicalEventClassifier @ 2022 Knowblesse Using the preprocessed Neural Ensemble dataset with behavior labels, build and test the Bernoulli Naive Bayes Classifier Along with the accuracy, feature importance is calculated. Two classification is done. 1) Is it HE or HW? 2) Is it data from Avoidance trial ...
e3068f02d28b1c7705feb0f543b566b696c4a5030521bb2347ba5faf8bdd27b8
Python
8,780
294
# -*- coding: utf-8 -*- import copy import os import nibabel as nb import numpy as np from scipy.signal import fftconvolve from ..io.filename import get_filename __all__ = ["calc_tsnr", "calc_mean", "calc_mean4d", "calc_std", "calc_acorr"] def calc_tsnr(file_in, tsnr_max=200, write_output=False, path_output=""): ...
44ebee79f3e65efc5fe754023a4e34d4aa9b62a31c36be2d4c02874cbc81d084
Python
8,782
238
import torch from torch_geometric.nn import MessagePassing import torch.nn.functional as F from torch_geometric.nn import global_mean_pool, global_add_pool from ogb.graphproppred.mol_encoder import AtomEncoder,BondEncoder from torch_geometric.utils import degree import math ### GIN convolution along the graph structu...
67eb6bd82b86aa4c46f63cc34982505e1fcfc9089333d34df917ebe97c231c75
Python
8,782
206
# /------------------------------------------------------------------------------+ # | 19-JUL-2022 | # | Copyright (c) Bone Imaging Laboratory | # | All rights reserved ...
d81f82d189e01ebbfcd8d27fea1a0dddc9acd48f8b8050e7781ba307da4baefc
Python
8,782
288
#!/usr/bin/env python """ This file contains the base illumination hardware class as well as a buffered variant. Any hardware that will be used for illumination control should be a sub-class of one of these classes. Hazen 04/14 """ from PyQt5 import QtCore def removeChannelDuplicates(queue, channel): """ Re...
0ce6b1788013e62820b31b4d15cc2b9ddf04c803580d8369f6e7c14b2b145aab
Python
8,784
237
""" imzML → AnnData Conversion Pipeline ==================================== Converts mass spectrometry imaging (imzML) data into an AnnData (.h5ad) object with spatial metadata, TIC normalization, and experiment annotations. Folder structure (relative to WORKING_DIR): WORKING_DIR/ ├── imzml_data/ ← input...
c946499284481a50cff2f79f0a07a0408e95993e915385b9915c7ba72dc92720
Python
8,784
216
import torch from torch import nn from torch.nn import functional as F from transformers import BeitModel, BeitConfig from torch.nn import init class ChannelPool(nn.Module): def forward(self, x): return torch.cat((torch.max(x, 1)[0].unsqueeze(1), torch.mean(x, 1).unsqueeze(1)), dim=1) class SpatialGate(nn...
9312fc7d59f7cbc13e1773f93cb31ccff0ef8ccc3050513770186875e55c37cf
Python
8,787
244
"""nsd_mapdata """ import os from nsdcode.nsd_datalocation import nsd_datalocation from nsdcode.parse_case import parse_case from nsdcode.load_data import load_transform, load_sourcedata from nsdcode.transform_data import transform_data __all__ = ["NSDmapdata"] class NSDmapdata(): def __init__(self, base_dir): ...