sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
49c59b8e6a643b84760e763f3cc4c6e6b906ef21398303cf6b40b6239a27a946
Python
4,661
126
import torch from torch import Tensor import torchvision.ops.boxes as bx from typing import Tuple, List import numpy as np from os import name WINDOWS = name == 'nt' __all__ = ['nms', 'contours2boxes', 'pairwise_box_iou', 'pairwise_generalized_box_iou', 'filter_by_box_voting'] def torch_compile(*args, **kwargs): ...
4e14987f599ac4a2fbd4ca593ef1318d6117afef7dfb1d6e072554729ecc1610
Python
4,661
108
from brainscore_vision.model_helpers.check_submission import check_models import functools import numpy as np from PIL import Image import torch import torchvision.transforms as transforms import torchvision.models from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper from brainscore_vi...
5708b33801d9562338222ca7bac63aecd35aa40c6c1ba76e1e0e4befe1e6939e
Python
4,661
125
from __future__ import print_function import torch def normalize(x, axis=-1): """Normalizing to unit length along the specified dimension. Args: x: pytorch Variable Returns: x: pytorch Variable, same shape as input """ x = 1. * x / (torch.norm(x, 2, axis, keepdim=True).expand_as(x) + 1e-12) ...
914aa2abab4741b4c2fe7b4f5a2d0c0eed5ccc64c0ad926b0c53401d542b5c18
Python
4,661
136
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Assign a custom color to a surface based on a data per point (dpp) file or an anatomical image. If a dpp file is provided, it must contain a scalar value for each vertex. If an anatomical image is provided, the color is sampled from the image at each vertex location....
be567f5066551da3c783a576d867589db1acbf91f84c896d469cc18c69ec3b00
Python
4,661
136
#cd Desktop/GCN/pygcn/env2/ import os,csv,re import pandas as pd import numpy as np import scanpy as sc from scipy.sparse import issparse from anndata import AnnData import torch from sklearn.decomposition import PCA import math import matplotlib.colors as clr import matplotlib.pyplot as plt from . models import * cl...
29c7a61103503aee7acd2179fcfef7451025cb3fab0b26b49787c0a8fd483170
Python
4,662
106
from scipy.misc import imresize import datajoint as dj from datajoint.jobs import key_hash import cv2 import numpy as np from commons import lab import os from .utils import h5 from . import experiment, notify from .exceptions import PipelineException schema = dj.schema('pipeline_posture', locals()) @schema class ...
3fb1707645abf7a3536151b58934eead828af1c89080f438e1aa7f81a4728e65
Python
4,662
100
import numpy as np from brainscore_core.supported_data_standards.brainio.assemblies import BehavioralAssembly from brainscore_core.supported_data_standards.brainio.packaging import package_data_assembly import pandas as pd ''' ** NOTE: This benchmark (cue-conflict) has a very different stimulus sets then ALL others,...
a6dc4ecffe24d70cb5487bff4c0fc033d28c8619d86449013445c71ae57bb23c
Python
4,664
108
from brainscore_vision.model_helpers.check_submission import check_models import functools import numpy as np from PIL import Image import torch import torchvision.transforms as transforms import torchvision.models from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper from brainscore_vi...
ec853c2412f536c565a977ceaee57b334a245b7143cc1e63cff3c5b49af59c8e
Python
4,664
129
import random from natsort import natsorted import matplotlib.colors as mcolors import matplotlib.cm as cm import pandas as pd from typing import List, Any, Tuple from pathlib import Path from brainglobe_atlasapi import BrainGlobeAtlas from napari.utils.notifications import show_info SEABORN_STYLES = {"white", "dark",...
742d1e3a1f9df519e5cb8917bc09b5178adcde924335f7b6ae9641c28d168257
Python
4,666
162
############################################################################### #################### Boilerplate ######################## ############################################################################### import pandas as pd import matplotlib.pyplot as plt import os import matplotlib...
3ca3b21afcaca21932f1d4b2b62da364afcddb21dfa3cf596453dfc51e0494d6
Python
4,667
143
''' CH5O2 ''' import numpy as np import sys def intro(): print(""" SHORT List of potential energy surfaces for CH5O2: 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 a...
518d035dcb57513b07b5fe898c6cc27da65a8c820fd0d42d2587cb822daee11d
Python
4,667
161
#!/usr/bin/env python3 """ Detect library layout (single-end or paired-end) for SRA accessions. Uses NCBI's esearch and efetch utilities to query SRA metadata. Falls back to detecting from downloaded files if metadata query fails. """ import sys import subprocess import xml.etree.ElementTree as ET from pathlib import...
4456547bb09b0cdfa46e691719867e1803347ffeb587048601a7ff04d4266519
Python
4,668
161
import sys import importlib from types import SimpleNamespace import numpy as np from musclex.algorithms.calibration_refinement import adapter def test_center_method_selection_cascades_to_required_previous_stages(): assert adapter._ordered_center_methods(["gradient"]) == [ "registration", "gradi...
fa8a8664e1cfef3cc9276688a31b12a99297df828a0c6b224d7a2ea8da5c9e7f
Python
4,668
127
# Copyright (C) 2020-2022 Intel Corporation # Copyright (C) CVAT.ai Corporation # # SPDX-License-Identifier: MIT import numpy as np import os import cv2 import torch from networks.mainnetwork import Network from dataloaders import helpers def mask_to_rle(mask): [height, width] = mask.shape pixels = (np.asarr...
00e4394079a306733c20bd5b9837f2c6d7449deb740aa6125c0430de09cf19b2
Python
4,669
177
#!/usr/bin/env python """ The core functionality for a QPD, QPD/Camera or z stage. Hazen 04/17 """ import storm_control.sc_hardware.baseClasses.hardwareModule as hardwareModule class LockFunctionalityMixin(object): """ Combine this with either a HardwareFunctionality or a BufferedFunctionality depending...
a457d4dd2b5d3e459902a0b27e7b4a0534ba6e540c778f373995cdf17e824e67
Python
4,669
111
#!/usr/bin/env python3 import pandas as pd import numpy as np import argparse import gzip import os import itertools from collections import defaultdict import tempfile def load_isoform_results(rsem_output, cols=None): dtype = {'transcript_id':str, 'gene_id':str, 'length':np.int32, 'effective_length':np.f...
420aff1e01a298b80d5b18cb0c69f488679ddc9c6f66ece990959d55c340c5ac
Python
4,670
123
''' Quick script to traverse all participant data in the experiment folder and estimate the free energy model at any point in time for each participant. Note that this script handles _all_ spaces, but not necessarily at once. E.g., a 'normal' run of this will run spaces for speaker-specific and -invariant priors with...
ac47641dbc964593410dda18ab7f5a095b2c7f306b91326063d50c1a4b0d87b4
Python
4,670
121
# Copyright (C) 2018-2022 Intel Corporation # Copyright (C) CVAT.ai Corporation # # SPDX-License-Identifier: MIT import zipfile from pathlib import Path from typing import BinaryIO from datumaro.components.annotation import AnnotationType from datumaro.components.dataset import StreamDataset from datumaro.components....
b313c67689c5337a2bed0c5a5b468b12a345299def3a069e05f17ee232289436
Python
4,670
109
import argparse import utils import plotting import keras from keras.models import load_model from os.path import join import numpy as np import gc ''' Get the average predictions from all models in a DeepSTARR ensemble on a test set. Options: - `--eval` flag: evaluate model performance on the test set. - `--...
cceb46def491899c90bacc9635c59852bc71f3fffaf0e741fc15b0ead6f40864
Python
4,671
157
import sys import yaml import os import numpy as np import re pathpath,myrun,ncluststr,cmethod,get_rois_bool_str,roi_tag = sys.argv[1:] with open(pathpath, 'r') as myfile: pathdict = yaml.safe_load(myfile) sys.path.append(pathdict['code']['workspace']) from pfcmap.python.utils import unitloader as uloader from pf...
9398d49bcd2e3ef720200c6da22c5e71602aead1fff96010eb0e451ea209820e
Python
4,672
126
#!/usr/bin/env python # -*- coding: utf-8 -*- """ The NAWM (Normal Appearing White Matter) is the white matter that is neighboring a lesion. It is used to compute metrics in the white matter surrounding lesions. This script will generate concentric rings around the lesions, with the rings going from 2 to nb_ring + 2, ...
17a78f2536d1f95eed7eeb15cb2bb8d3c2fab98d444e21ae62380fd551eabcca
Python
4,673
119
# Copyright (c) 2022, Kwanhyung Lee. All rights reserved. # # Licensed under the MIT License; # you may not use this file except in compliance with the License. # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTI...
ad880511c09170d7cb9ecd488a302041e0318d4d22b67fd706cef32f79de25d1
Python
4,673
113
from pathlib import Path from typing import Optional, Union from loguru import logger from brainles_preprocessing.registration import ANTsRegistrator from brainles_preprocessing.registration.registrator import Registrator class Transform: """ Class to apply precomputed transformations based on the registrat...
e7664b7249561459483f68e9b7b1aa936e29a8be4273c2ea8b3bb93e8625af17
Python
4,673
104
############################################################################# # Copyright (C) 2020-2026 MEmilio # # Authors: Maximilian Betz # # 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 Li...
0d696283156f7c2f0bc2255a1319ef51a39feb040912b1eee29b83d25ddda36c
Python
4,674
84
import pytest import numpy as np from brainscore_vision import load_dataset, load_stimulus_set from brainscore_vision.benchmark_helpers.neural_common import filter_reliable_neuroids TOTAL_VOXELS = 18394 NOISE_CEILING_THRESHOLD = 0.3 * 100 EXPECTED_RELIABLE_VOXEL_COUNTS = { '01': {'IT': 250, 'V1': 385, 'V2': 257, '...
777b2cda0ba382f4d0e89acb5601de15225fbe3b8dcb5e9b750d084660b42cdf
Python
4,674
154
# -*- coding: utf-8 -*- # python standard library inputs import os # external inputs import numpy as np import nibabel as nb from sh import gunzip from scipy.interpolate import InterpolatedUnivariateSpline as Interp # local inputs from ..io.get_filename import get_filename def regrid_time_series(file_in, path_outp...
f1c4e39a2807cd70343a6e9dcdb866e5f73a030f188979d14cab24ec781e76a8
Python
4,674
126
from __future__ import annotations from typing import Final from typing import cast from loguru import logger RGB_CHANNEL_COUNT: Final = 3 def _is_rgb(value: object, /) -> bool: CHANNEL_VALUE_MAX: Final = 255 return ( isinstance(value, list) and len(value) == RGB_CHANNEL_COUNT and ...
630e6eeaeb40ded0e13536efaffa19397d86d5288beb6caa2beb8ef60a8253e6
Python
4,676
119
import numpy as np import torch from torch import nn # from transformers.modeling_distilbert import Transformer as _Transformer class CNNTransformer(nn.Module): """ https://github.com/i-pan/kaggle-rsna-pe/blob/main/src/beehive/models/sequence.py https://discuss.pytorch.org/t/nn-transformerencoder-for-cla...
a6df9fff2287c55306d82d41a72ac42c067a9718a778b46c9d5acf9474592a58
Python
4,676
134
import os import numpy as np import librosa from torch.utils.data import Dataset from torchvision import transforms import sys sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) from datasets.dataset_scale import DatasetScale class AudioVelDirDataset(Dataset): def __...
3f4117dee81b4ac0f13c6e367bab4d17d41af5111645ee086f150af01da6a983
Python
4,678
135
import os import torch from torch.utils.data import Dataset from torchvision import transforms import numpy as np import matplotlib.pyplot as plt import sys sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) from datasets.audio_dataset import AudioDataset from datasets.accel_dataset_mel i...
6579ee0f844acaace802ea024b55a16ac6b8459f791b6f26556ef702d7ca0799
Python
4,679
277
import numpy as np from impedancefitter.double_shell_wall import ( double_shell_wall_model, eps_cell_double_shell_wall, ) from impedancefitter.double_shell_wall_ellipsoid import ( double_shell_wall_ellipsoid_model, eps_cell_double_shell_wall_ellipsoid, ) # for double_shell_wall_model c0 = 1.0 em = 10...
8b36b42e6a4a61742c07e026c64bf903898b57f329088badc73b2edc892ac314
Python
4,679
116
import argparse import os import random import sys import numpy as np import pandas as pd import torch from torch import optim import torch.nn as nn from torch.utils.data import DataLoader from sklearn.model_selection import KFold from utils.datasets import NewDataset, get_transform, TestDataset from mode...
a5eb9c983730a4a46552a32ebf4bd887d527c51c0b6cc3200978d6c6277d1afe
Python
4,679
40
from testsetclass import TestsetClass class BH76RC(TestsetClass): def __init__(self): self.weak = 1.0 self.molecules = ['hcn', 'n2', 'N2H2', 'hfch3ts', 'NH3', 'hclhts', 'fch3clcomp2', 'hf2ts', 'RKT09', 'f', 'ch3cl', 'fch3fcomp', 'RKT06', 'c2h4', 'RKT04', 'RKT21', 'RKT05', 'hn2ts', 'RKT17', 'RKT03'...
f0ed00d89bf3d14a6408bf307313d9173e924c0f409748da2c584b547317720e
Python
4,679
142
import numpy as np from numba import guvectorize, float64 import logging import tvb.simulator.lab as lab from tvb.contrib.cosimulation.cosim_monitors import RawCosim as CoMonitor from tvb.contrib.cosimulation.cosimulator import CoSimulator from tvb.simulator.models.wong_wang import ReducedWongWang, Final, List from tv...
5aedfb7e3c86f64ac4e2736d499b9bd548e109a18a942973e0d660a826256861
Python
4,681
93
# Gibbs ringing removal with DIPY (local subvoxel shifts, Kellner et al. 2016; the method of MRtrix mrdegibbs), slice by # slice in the plane of acquisition. Meant for full Fourier acquisitions; with partial Fourier it removes only part # of the ringing. Use it after DWI_Denoise and before any interpolation (eddy...
78e08ad47b154889ce45d98de87923278ac019d708c86284cb7d9b306ce129f7
Python
4,681
134
""" Body-part specific IVIM parameter defaults. Literature-based initial guesses for different anatomical regions, using expected healthy-tissue means from the upcoming Sigmund et al. IVIM consensus recommendations paper ("Towards Clinical Translation of Intravoxel Incoherent Motion MRI: Acquisition and Analysis Conse...
615d7d2381b0a71d1e00b1209556796d1a3f6f0f607bdc3234410dfafe484d15
Python
4,683
97
from . SpaGCN import * from . util import * from . calculate_moran_I import * from . calculate_adj import * def detect_spatial_domains_ez_mode(adata, img, x_array, y_array, x_pixel, y_pixel, n_clusters, histology=True, s=1, b=49, p=0.5, r_seed=100, t_seed=100, n_seed=100): adj=calculate_adj_matrix(x=x_pixel,y=y_pixel...
fc735ebff9e4174bcb405be44122aef261655c9a8c879fef4ac4b2c2d2eb3c09
Python
4,683
134
""" Aspen Plus PEMFC Experimental Data Generator Generates realistic PEMFC polarization data mimicking Aspen Plus process simulation output. Data characteristics: industrial-scale stack, validated against experimental literature. """ import numpy as np import pandas as pd import json from pathlib import Path def gen...
2bb0b8caeb926c3dc71403c1e70369658ec55b309a6830ad2b4aa9a0ef49a4da
Python
4,684
133
""" Copyright 1999 Illinois Institute of Technology Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publis...
d2c0a1871880e5dcccd865c6a8332cd73db62b8614d678140509143640f68a93
Python
4,684
134
"""Parsl execution backend. Wraps `Parsl <https://parsl-project.org/>`_ to conform to the :class:`ExecutionBackend` interface. Python tasks are dispatched via ``@python_app`` and shell tasks via ``@bash_app``. Parsl must be installed separately (``pip install chemgraph[parsl]``). """ from __future__ import annotati...
f0fd67367d2ac2ce2af031e6f8dd7132c4893aced1a76ab1ee045542bcc51fce
Python
4,684
133
def test_parallel(): import numpy as np databases = {} neurons = 100 timepoints = 3600 orientations = 4 directions = 8 behaviors = 2 orientations_labels = ["0", "45", "90", "135"] directions_labels = ["0", "45", "90", "135", "180", "225", "270", "315"] behaviors_labels = ["speed...
95409971cb90358f207d8533f9846b35e49572462e209485696fe6d87329de26
Python
4,685
118
from typing import Optional import torch.nn.functional as F from torch import Tensor from torch.nn.modules.instancenorm import _InstanceNorm from torch_geometric.typing import OptTensor from torch_geometric.utils import degree, scatter class InstanceNorm(_InstanceNorm): r"""Applies instance normalization over e...
ab9897cc040a107e88691c3b7c80c319235c9148cd8822e68affe36bd07e49c0
Python
4,686
122
# 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 math from typing import Any, Optional import torch import torch.onnx.operators from fairseq import utils from torch import nn, Tensor ...
4f53d8d7d7e0e44341ee87ace5ab5b2debfd3fadefed34ee5518fedb68ca9972
Python
4,690
116
# 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 typing import List import torch.optim.lr_scheduler from unicore.optim.lr_scheduler import UnicoreLRSchedu...
534a6096f2dc28be7602051d791532ddf561deec8bd0d12cd5b01c5c23abdc42
Python
4,693
127
""" Utils for mTRF analyses """ import numpy as np def segment(arr, n_segments): """ Cuts the data into equally-sized fragments for mTRFpy. Takes an array and the number of segments Works on arrays of different dimensions but uses slices it along len(arr) i.e. along the first dimension or horizontally ...
6cfdc42e170f630071b3449fb83668bdc35458937585b0d46ca3236b1570a486
Python
4,693
103
import pathlib import re from collections import defaultdict from typing import Tuple import neuron_interface.neurosim compartment_names = { "all": "all", "axonal": "axon", "basal": "dend", "somatic": "soma", "apical": "apic", } def convert_hoc_to_python_cell(cell_type: str) -> Tuple[str, str]: ...
8960463d1b9bab2ee8316e530935c2db080445233664520c75171498929f231f
Python
4,693
142
from __future__ import annotations from typing import Optional, Tuple # TODO: remove kornia dependency import kornia.geometry as KG import numpy as np import torch from torch import Tensor from torchvision.transforms.functional import to_tensor from brainways.pipeline.brainways_params import AffineTransform2DParams ...
8a98c592b54715afb9456be7633e25a5e773960b9a67d6704f8828a837c0a5ea
Python
4,693
133
import torch import torch.nn as nn import numpy as np import torch.nn.functional as F from torch.nn import init class ConvGRUCell(nn.Module): """ Generate a convolutional GRU cell """ def __init__(self, input_size, hidden_size, kernel_size): super().__init__() padding = kernel_size //...
c42555a3127e6d900901abff30754d23f589e222bb8611b8ce681ca65cb87e9f
Python
4,693
144
"""Flat-folder dataset of individually preprocessed images.""" from __future__ import annotations import os from typing import Any, Callable import numpy as np import pandas as pd import tensorflow as tf from numpy.typing import ArrayLike from pyment.loaders.mgh import load_mgh from pyment.utils.strip_extension imp...
1034ac93d5aa1921333e04608dc239dc9d7b3d8052c0fcf97f1004db950a552b
Python
4,694
144
# /------------------------------------------------------------------------------+ # | 22-AUG-2022 | # | Copyright (c) Bone Imaging Laboratory | # | All rights reserved ...
cf39227e97a28717abad8cca444d9e05a702cc3247b52c83cefdc13331e91381
Python
4,694
126
''' Collects all behavioural data from the learning task and outputs it to: ./data/preprocessed/beh/all_mt1.csv OPTIONS: None EXAMPLE USAGE: python beh_preprocess_mt1.py ''' import numpy as np import pandas as pd import mne, os, sys, copy import auxiliary as aux import data, rsa import gzip, pickle, tim...
cd57b87723e7e84453bb2cdf190d5b196940dff4ddfb21b42cbdb71c1be2b845
Python
4,695
103
from pathlib import Path import pytest from pytest import approx from brainscore_vision import benchmark_registry from brainscore_vision.benchmark_helpers import PrecomputedFeatures from brainscore_vision.benchmark_helpers.test_helper import StandardizedTests, PrecomputedTests, NumberOfTrialsTests, \ VisualDegree...
41201d8b46b210fb09f6533c73bcee85d4476e2b8329e3f8538859e001258d34
Python
4,697
112
import scipy as s from .basic_distributions import Distribution from .bernoulli import Bernoulli from .univariate_gaussian import UnivariateGaussian from mofapy2.core.utils import * class BernoulliGaussian(Distribution): """ Class to define a Bernoulli-Gaussian distributions (for more information see Titsias ...
97d97be27045ebd23350c32529974f2ec6f22e18d7067991fca202f1f1ac4730
Python
4,698
161
#!/usr/bin/env python # # A script to submit analysis jobs to the SLURM queuing system # # Derived from submit_slurm.py # F. Nedelec, 18.11.2018 """ Submit a job to the SLURM system to be called in multiple directories Syntax: submit_one.py ARG [mem=????] [queue=????] [hours=INT] [days=INT] dir1 [dir...
2643909a596d3cba8d6c091f7bb39db134bc36f81b367def3a9187365c575297
Python
4,699
125
import os import torch import torch.nn as nn import torchvision.models as models def resnet18_fixed(num_classes): # Using a pre-trained ResNet model adapted for grayscale images model = models.resnet18(pretrained=True) # Modify the first convolutional layer original_first_layer = model.con...
543e6168c137e36408da917b496bbac6e28a51bcd9e2b8253d6c2f90244231ea
Python
4,699
91
import brainscore_vision from brainscore_vision import load_metric, load_ceiling from brainscore_core.supported_data_standards.brainio.assemblies import walk_coords, array_is_element from brainscore_vision.benchmark_helpers.neural_common import NeuralBenchmark VISUAL_DEGREES = 2 NUMBER_OF_TRIALS = 2 BIBTEX = """@artic...
de835aee99fda369c9dcb7e88862800fe486183b443abb30fd6a85209c98a6f1
Python
4,699
131
# py imports import os import sys import glob from argparse import ArgumentParser import time # third party import tensorflow as tf import scipy.io as sio import numpy as np from keras.backend.tensorflow_backend import set_session from scipy.interpolate import interpn import scipy.ndimage # project sys.path.append('....
61545143c62c7dd6ab64451d6948ccf25941c0d99e0cda4e0b6e097e52206239
Python
4,701
109
#!/usr/bin/env python # Copyright (c) 2015 Tobias Neumann, Philipp Rescheneder. # # This file is part of Slamdunk. # # Slamdunk is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the #...
73b965e6ca2384bb0ddf3da0825153a610ffd206450725d2a721e9a4820151fe
Python
4,702
127
import pandas as pd import matplotlib.pyplot as plt import scanpy as sc import numpy as np import os from typing import List, Optional from tqdm import tqdm def plot_spatial_celltypes( st_visium_path: str, count_file: str, library_id: str, image_path: str, pred_csv: str, cell_type...
7fdec1382a20c1c0ddf0734d4a1ee0a0fe7696afee57754d608fee8ae68eaab5
Python
4,702
152
# -*- coding: utf-8 -*- """ Created on Mon Sep 18 19:27:36 2023 @author: szh """ import numpy as np import torch import torch.nn as nn import torch.backends.cudnn as cudnn cudnn.deterministic = True cudnn.benchmark = True import torch.nn.functional as F from torch.nn.parameter import Parameter from torch.nn.modules.m...
d880eb3661996dcbab1a317ab45ae23d27ee02a38bc60563f93d4a93bc7b0122
Python
4,702
145
"""Provide helper functions or classes for defining loss or metrics.""" from typing import List, Optional, Union import tensorflow as tf from deepreg.loss.kernel import cauchy_kernel1d from deepreg.loss.kernel import gaussian_kernel1d_sigma as gaussian_kernel1d class MultiScaleMixin(tf.keras.losses.Loss): """ ...
2d412531b91cf45700f04ec4343966dde280d5136c1176a8893d3f8d52b0fb5f
Python
4,704
113
"""Reservoir-computing export matrices from stim-aligned spikes. Port of STEP 5.1d / STEP 7 / STEP 8 of ``stimActivityAnalysis.m`` (origin/main): ``FiringRateMatrix``, ``latencyMatrix`` and ``ExactSpikeTimes``, each ``[numTrialsTotal x numChannels]`` over the consolidated (all-pattern, chronological) stim times. All ...
d08b2b0384915df552610dbd76abba7e19f53615289754c404b9aa0150ecccb6
Python
4,704
114
"""Demonstrates how to build models using keywords.""" from nems import Model from nems.layers import STRF, WeightChannels, FIR, DoubleExponential, WeightChannelsGaussian from nems.registry import keyword_lib # View all defined keywords keyword_lib.list ######################################################## # Usin...
16eaad232220386f510ca8dfab8655e63699977149a4daf9ce9c6f374e6777a9
Python
4,706
134
# 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. from typing import List, Optional import torch import torch.nn as nn import torch.nn.functional as F class ImageEncoder...
2a577584cf1cb8137563c4d06a0d515026ca1880bf44b9d6f9c2e3b29decaa57
Python
4,706
145
# -*- coding: utf-8 -*- # python standard library inputs import os import sys import datetime # external inputs import numpy as np import nibabel as nb from nibabel.freesurfer.io import read_geometry, write_geometry from nighres.laminar import profile_meshing from gbb.io import get_filename # local inputs from ..io....
7126828e96178cafb0fc9c210ec9233b016cae933e61616ea574978239b018f5
Python
4,706
90
from pathlib import Path import pytest from pytest import approx from brainscore_core.supported_data_standards.brainio.assemblies import BehavioralAssembly from brainscore_vision import benchmark_registry, load_benchmark from brainscore_vision.benchmarks.baker2022 import DATASETS from brainscore_vision.benchmark_helper...
137d5e3c97fd7b1d52aa6480c2e08cfa9eccc01c8bc99e7baac81b9e61d521d0
Python
4,707
124
# /------------------------------------------------------------------------------+ # | 19-JUL-2022 | # | Copyright (c) Bone Imaging Laboratory | # | All rights reserved ...
9c250df3d1186f7c0e01c806aad0ad6a3c3223e97e9d58a98c7a5e95372e1c37
Python
4,707
163
# Copyright (C) CVAT.ai Corporation # # SPDX-License-Identifier: MIT import os import tempfile import unittest from types import TracebackType from unittest.mock import patch from datumaro.components.dataset import StreamDataset from datumaro.util.os_util import rmfile, rmtree from cvat.apps.dataset_manager.bindings...
b7dd95ef4333133d968fa906c9ea271d217c86dedaea757bee2771188330f123
Python
4,707
132
"""Persistence adapter for direct main-agent subgraph invocations.""" from __future__ import annotations import logging import uuid from typing import Any from langgraph.errors import GraphInterrupt from chemgraph.memory.serialization import serialize_messages from chemgraph.memory.store import SessionStore _RUN_...
d7e4bf307fc30a5ba48613bc78546acbd8b6007969084cb50ff0060d16ca1e3a
Python
4,707
162
# -*- coding: utf-8 -*- # # Configuration file for the Sphinx documentation builder. # # This file does only contain a selection of the most common options. For a # full list see the documentation: # http://www.sphinx-doc.org/en/master/config # -- Path setup ------------------------------------------------------------...
f4b3f07edcb6c37c6eb57a741c48f99c9ff063a92acb3af8cd20e9497ad9bf41
Python
4,707
132
# -*- coding: utf-8 -*- """ Make layer This script computes equidistant layers between a white and a pial surface. The following steps are done: (1) match vertex numbers of both surfaces (2) extract main component to remove unconnected parts (3) inflate white surface for visualization (4) compute meshl...
7cbee4b2935be000521e051b99a9941c84841ee8d0416ffcb83c5e22322f1f91
Python
4,709
147
"""Shared model-loading utility for ChemGraph. Provides a single ``load_chat_model`` function that detects the endpoint for a given model name and returns a LangChain ``BaseChatModel`` instance. This is the only model-routing entry point; the pipeline is:: caller -> load_chat_model -> endpoint spec -> protocol bu...
cc0f2745dbb299070e41404690630e4fc4bc849a9ff01efbd5492ea1f1b05673
Python
4,709
101
import numpy as np from scipy.stats import spearmanr from brainscore_core.supported_data_standards.brainio.assemblies import DataAssembly, walk_coords, NeuroidAssembly from brainscore_core.metrics import Metric, Score from brainscore_vision.metric_helpers import Defaults as XarrayDefaults from brainscore_vision.metric...
b940f160ee0bfcca03dc8a6220f35036a5e5c55be062d333a0307f47b1262985
Python
4,710
113
import numpy as np from scipy import stats from utils import Recorder, Q_nak from mitochondria_PDP1KD import Mito import matplotlib.pyplot as plt from figure_properties import * dt = 0.01 def regular_spiking(sp_hz, spike_dur, q, t_start=150, t_run=1000, t_ca=5000, ca_fact=0.1): time = t_run + t_start + spike_dur...
3c79f480908dace646ae7d1bde27f8dde5af94c209bbec2358b28f3aaf271ec7
Python
4,711
122
import torch import torch.nn.functional as F from monai.losses import DiceLoss, SSIMLoss, GeneralizedDiceLoss, FocalLoss, DiceCELoss from torch.nn import CrossEntropyLoss class DiceSSIMLoss(torch.nn.Module): def __init__(self, beta=0.5, sigmoid=True, class_weights=None): super().__init__() self.be...
b7daa5b7172aae8b86ee9aba9dc7ec87cba75c724cce33bb94ecb68d76fb1175
Python
4,713
90
#!/usr/bin/env python3 # # make_datasheet.py # # Datasheet (CSV) for EXTRACT_Profile from a reference dataset organized as <subject>/<session>/...: one row per scan, # with the case id and one column per image. Each --column is NAME=PATTERN, the pattern a glob relative to the session # folder. The first column ...
d76b7fc00996b8938cfb2170462a7ef4228d149fed4912721e62bd8bf2c5aa0d
Python
4,713
107
""" Helper functions for building the model. """ import numpy as np import pandas as pd import torch from torch import nn def np_to_torch(arr: np.array, dtype: torch.float32, device: str = 'cpu'): """Convert a numpy array to a torch.tensor Parameters ---------- arr : np.array dtype : tor...
ab8c42b7b2702b2a0a4c798d875a0ab627e466ea8111e28ec5c9f028ba9d53cd
Python
4,716
117
""" HMM: Multitaper Spectra ======================= In this tutorial we calculate subject and state-specific multitaper spectra using a trained HMM and **source space** data. Here, we should **not** use the prepared (e.g. TDE-PCA) data. """ #%% # Download source data # ^^^^^^^^^^^^^^^^^^^^ # In this tutorial, we'll d...
99ef04a3faabf62e1ed7315c8e3affd3bfee0a5798d7d89d6ce7b7de98bc892e
Python
4,717
139
from __future__ import annotations from typing import ClassVar, TypedDict import polars as pl from argclz import argument, try_int_type from neuralib.atlas.ccf import RoiClassifierDataFrame from neuralib.atlas.ccf.dataframe import ROIS_NORM_TYPE from neuralib.atlas.typing import TreeLevel, Area, Channel, Source from...
a16c53acd5b2bdb4d33f0ceab17c609eefe27fcb45f8706a3d7d832765e8f871
Python
4,717
126
# -*- coding: utf-8 -*- from flair.parser.modules.dropout import SharedDropout import torch import torch.nn as nn from torch.nn.modules.rnn import apply_permutation from torch.nn.utils.rnn import PackedSequence class BiLSTM(nn.Module): def __init__(self, input_size, hidden_size, num_layers=1, dropout=0): ...
b09ef33cb5c683b661caa3470b39675cbb87a76022c460ed67047cddc0dce7d3
Python
4,717
124
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved # Adapted from https://github.com/stackav-oss/conch/blob/main/conch/kernels/vision/nms.py import torch import triton import triton.language as tl @triton.autotune( configs=[ triton.Config({"cxpr_block_size": 128}), triton.C...
18d2af9a8a0965f9147825de9b85779c5fb4b3b97b41893fcf21eb1e7ead6cbc
Python
4,718
199
# The ImpedanceFitter is a package to fit impedance spectra to equivalent-circuit models using open-source software. # # Copyright (C) 2018, 2019 Leonard Thiele, leonard.thiele[AT]uni-rostock.de # Copyright (C) 2018, 2019, 2020 Julius Zimmermann, julius.zimmermann[AT]uni-rostock.de # # This program is free ...
2e1de8ab9af6bec5d41865aacadfbc35f56bc26d555878d21df3c15face85db2
Python
4,718
150
#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- import os import sys from glob import glob def read_ml_inputs(ml_file): if not os.path.isfile(ml_file): print("Error: {} not found. Exiting.".format(ml_file)) sys.exit(1) lines = [] with open(ml_file, 'r') as f: for line in f: ...
9baea83aea51b24c199f3cdd7e53fff8994e70544d0ef57b25d93cd7fd0579be
Python
4,718
128
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Extract B0s from DWI, based on the bval and bvec information. The default behavior is to save the first b0 of the series. """ import argparse import logging import os from dipy.core.gradients import gradient_table from dipy.io.gradients import read_bvals_bvecs imp...
a4224c66a7207d1fd97379e501a0d5df2382a9f1b838af89c82669562501b0d1
Python
4,720
108
import argparse import utils import plotting import keras from keras.models import load_model from os.path import join import numpy as np import gc ''' Use ensemble of DeepSTARR models to make predictions on STARR-seq data and calculate ensemble average if --eval flag set, evaluates ensemble average prediction perform...
c022f9c0c153ac3dd4058ec3c06b33d1832af3ed71c27cab562417c0d21f5da5
Python
4,720
107
""" January 2022 by Paulien Voorter p.voorter@maastrichtuniversity.nl https://www.github.com/paulienvoorter requirements: numpy tqdm scipy """ # load relevant libraries from scipy.optimize import curve_fit import numpy as np import tqdm def two_exp_noS0(bvalues, Dpar, Fmv, Dmv): """ bi-exponential IVIM functi...
e132e7b4b26c4efa2dc8d482ff062d3a76c5b9f1fdbc01209cc509b16be2140b
Python
4,720
159
# -*- coding: utf-8 -*- """Behavioral measures.""" import os import sys import matplotlib.pyplot as plt import numpy as np from matplotlib import rc from scipy.io import loadmat __all__ = ["analysis_fixation", "get_onset_vols"] # font parameters for plots rc("font", **{"family": "serif", "serif": ["Palatino"]}) rc(...
f660b25ebf80c2ca46997b5d6e9a0b6c4d9f54b48ab2985e18d6dcc1b3c9cae6
Python
4,720
174
import io import json import os import re from importlib.resources import files import cloudfiles import pandas as pd from skeleton_keys.database_queries import (layer_polygons_from_database, pia_wm_soma_from_database, query_for_i...
bb1d09460d10b98b2522aeacdc7b582673862a08873ba4e38ebcecdb88fd0fe5
Python
4,721
103
import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns from sklearn.neighbors import LocalOutlierFactor from sklearn.preprocessing import StandardScaler, OneHotEncoder, LabelEncoder from sklearn.compose import ColumnTransformer from sklearn.decomposition import PCA from sklearn.mod...
6f9ed7bcd7a4ad46060e33499467aabda306349987c28a52174ff2c815a52ee0
Python
4,722
122
import torch from torch import Tensor from torch.nn import BatchNorm1d, Linear class DiffGroupNorm(torch.nn.Module): r"""The differentiable group normalization layer from the `"Towards Deeper Graph Neural Networks with Differentiable Group Normalization" <https://arxiv.org/abs/2006.06972>`_ paper, which n...
7025718e9fba1cbd48deec823edbdf348d0935067f6dce7a33ec9c4616561d03
Python
4,722
117
"""The three pipelines MEA-NAP ships, and which GUI tabs each one needs. MEA-NAP is really three pipelines sharing one window, and each reads a different slice of the settings. Showing every tab regardless means most users spend most of their time looking at settings their run will never read — worse, at settings that...
acbf59d809f7b3534b032fbec2ae4b7fbaaf663483dde21f5ea6c24febd25d96
Python
4,722
135
# !/usr/bin/env python # coding: utf-8 # @Time : 2022/7/17 13:54 # @Author : Z.-H. G. # @Email_0 : guozhenhao17@mails.ucas.ac.cn # @Email_1 : guozhenhao@tongji.edu.cn # @File : params.py # @IDE : PyCharm import pandas as pd # TODO dict? yaml? # all query PARAMS = \ {'preprocess': { ...
8ede15ed1a0da67cbbd52521b041dde17cf70b09e13cf2ade920a8568650fb9c
Python
4,726
130
"""Probabilistic edge thresholding, port of ``adjM_thr_parallel.m``. Generates synthetic spike trains by circularly shifting each channel's real spike times by a random offset, recomputes STTC on the shuffled data, and zeroes out any edge whose real STTC value doesn't clear the ``tail`` significance cutoff across ``re...
857510b5f9bb487429da57b4b49b9344840b87a2d2fd0d7ed5370fd7a2422414
Python
4,729
140
import argparse import logging import os import sys import uvicorn from mcp.server.fastmcp import FastMCP def run_mcp_server( mcp: FastMCP, default_port: int = 8000, default_host: str = "127.0.0.1" ): """Standardize the startup process for ChemGraph MCP servers. Supports 'stdio' (default) and 'sse' (HTT...
3a32d4a8ee6f31fce263e25c947b84c17f64f6f657f22eae47c3c80a162de575
Python
4,730
190
#!/usr/bin/env python # coding: utf-8 # In[ ]: """ AGED: Attention-Guided Enhanced Deconvolution A novel deep learning framework for spatial transcriptomics deconvolution that combines probabilistic initialization with multi-scale attention mechanisms. """ __version__ = '0.0.1' __author__ = 'Xiao Yang' __email__ =...
69e3236a21e37e53a9e68947c9941fe7a22a7949b57b788ba98e58508dbd3b72
Python
4,731
145
#!/usr/bin/python # -*- coding: latin-1 -*- # ============================================================================================= # Librairies importation import numpy as np import nrrd import sys import os import multiprocessing as mp # ===================================================================...
172d0a01d0c24c7b2b5a178caf7a2cbdc3e6c146772e442b518397e451f35ac3
Python
4,732
111
import numpy as np from dipy.core.gradients import gradient_table from src.wrappers.OsipiBase import OsipiBase from src.original.fitting.IAR_LundUniversity.ivim_fit_method_subtracted import IvimModelSubtracted class IAR_LU_subtracted(OsipiBase): """ Bi-exponential fitting algorithm by Ivan A. Rashid, Lund Uni...
1b1590307cc2f299134fd8a441a4c62b0bc32cf2b1706a9f39b61927f7c80fd4
Python
4,733
126
""" Adjusted version of script from original MRI2FEM-book according to below license. ''' Copyright (c) 2020 Kent-Andre Mardal, Marie E. Rognes, Travis B. Thompson, Lars Magnus Valnes Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "...
67c39de12d06dd41adbd14fad3c93d19a979b4a268d3eefae4ab52f67df4483e
Python
4,733
80
#! /usr/bin/env python """Generate a cropped mesh from a point cloud using pymeshlab and the screened poisson method. Usage: xyz2ply.py cloud.xyz mesh.ply""" __author__ = "Benjamin Barad" __email__ = "benjamin.barad@gmail.com" __license__ = "GPLv3" import math import click import pymeshlab as pm @click.command() ...
e795f15c14af0cfcb8d71c83378c954665b855663d2f7b0d6b304223bdce01ed
Python
4,733
93
import nighres import os import nibabel import numpy import glob inpath = '/home/public/InSitu/Processed/insitu_08_122017_xx_xx/release/' outdir = '/home/pilou/Projects/Cerebellum/Cerebellar-segmentation-ABC/ahead/coreg/' bf_img = inpath+'Ahead_brain_122017_blockface-image.nii.gz' thio_img = inpath+'Ahead_brain_1220...