sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
dbd665b2326466db7092852df00f9da47a8fecb9c017671db082c5d9160f1488
Python
5,902
147
from collections import OrderedDict from torch import nn import numpy as np from .modules import RetinaBlock, Bottleneck, VOneBlock, Identity from .params import get_dog_params, get_div_norm_params, generate_gabor_param from .backends import get_resnet_backend, get_vgg_backend evnet_params = { 'base': { ...
6c2cedda881975ec5609e84a7791d52a174b55cab317b6a6a31769914dbedb64
Python
5,904
146
"""Tests for mcmlnet.transforms.physiological module.""" from itertools import product import numpy as np import pytest import torch from mcmlnet.transforms.physiological import PhysiologicalToPhysicalTransformer class TestPhysiologicalToPhysicalTransformer: """Test cases for PhysiologicalToPhysicalTransformer...
b2c724de0d35970b515f70ddf7a523792e1575315d4810ce7f091883533f6e6e
Python
5,904
188
# Copyright (C) CVAT.ai Corporation # # SPDX-License-Identifier: MIT import csv import json import os import random import sys from itertools import product random.seed(42) NAME = "events" def read_rules(name): rules = [] with open(os.path.join(sys.argv[1], f"{name}.csv")) as f: reader = csv.DictRe...
2838aeb77df509e7e39a330045eac28e68629eaa1a024e2f54a71ed674467e6f
Python
5,905
140
from collections import Counter import anndata import anndata as ad import pandas as pd from torch.utils.data import Dataset, DataLoader import timm from timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from huggingface_hub import login, hf_hub_download from sp...
a4cd271bf2f0bcde32933c3e2e10fbef3c1686f31f1aff8b90b79c845189333e
Python
5,905
132
import numpy as np import matplotlib.pyplot as plt import csv import nrrd def extract_rgb_values(csv_file): color_data = {} with open(csv_file, 'r') as csvfile: reader = csv.reader(csvfile, delimiter=':') for row in reader: label, rgb_str = row[0], row[1].strip()[1:-1] # Extracti...
2863543685558b78eab2b3d53a9db0690ca8646132bcd8850032488cd11b9097
Python
5,907
162
#!/usr/bin/env python # author: Jannes Spangenberg # github: https://github.com/JannesSP # website: https://jannessp.github.io from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, Namespace import os import csv from pathlib import Path from collections import defaultdict import pysam import tqdm def pa...
e3161839f9e94226765319546698e6bfb263003999b5c2cc27d1de2a1253f381
Python
5,907
120
import os from pathlib import Path import json import numpy as np import xarray as xr import pandas as pd from brainscore_core.supported_data_standards.brainio.assemblies import NeuronRecordingAssembly from brainscore_core.supported_data_standards.brainio.stimuli import StimulusSet from brainscore_core.supported_data...
c9be69082dd7a7539ccf9d3745a37855749e18c9f678c86da29c4f7f025546c0
Python
5,908
123
import os from importlib import import_module from pathlib import Path cell_graph_config = { "cell_f_list": [ 'area', 'r_equiv', 'r_maj', 'r_min', 'angel', 'ecc', 'maj_x', 'maj_y', 'min_x', 'min_y', ], "edge_f_list": [ ...
1bd26befab86a091c68d1f740cd46574a94fdca45ca82ad85259d2c5dbad6f91
Python
5,909
290
#!/usr/bin/python3 # import os import sys import argparse import numpy as np from sklearn.neighbors import NearestNeighbors from uac import utils # Create the parser my_parser = argparse.ArgumentParser(description="Calculation of old atrial coordinates") # Add the arguments my_parser.add_argument("target_path", meta...
2d896b44c2905c74b1ada66a305f65da8a4b457351885edc64db1eaab0ac8430
Python
5,910
194
# -*- coding: utf-8 -*- """ Make eccentricity isolines This script computes isolines based on the phase map of a retinotopy measurement. The phase map is mapped onto the grid representation of a flattened surface patch. Only contour lines which are continuous are considered. The purpose of this script is to estimate c...
b4bd841e4039884996a7cbe109676a74db3aa98677df417d08e2118d7d097924
Python
5,911
159
import sys sys.path.append("/LiNet") import torch import numpy as np from torch.autograd import Variable import argparse import random import os import os.path as osp os.environ["OPENCV_IO_ENABLE_OPENEXR"] = "1" import cv2 import lib_alban.utils_test as utils_test from lib_alban.utils_analyse import load_and_process, l...
ea980026fdbf76705bb8f8276fece316d54948431fe9f6b1f792cc8b9b1378cf
Python
5,911
141
####################################################################################### ### Functions to calculate the mutual information from the firing rate distribution ### ### in a network at two different times ### ########################################################...
1bf4ceff46cba58143b65a8f603d81033b253f58834275ba60fc1a93df3a2269
Python
5,912
141
import numpy as np import glob import pickle import sys import PopSpikeAnalClass as psc import os import time import datetime from argparse import Namespace import pop_spike_utilities as psu ms_per_sec=1000 changedate=datetime.date(2021, 5, 12) #date file changed FVwidth and decay time units def find_files(subdir): ...
b5259e31fd8f7f2e0358ac29b45af58e6509c054c27ae458826749eeefcf4df7
Python
5,913
163
import numpy as np import networkx as nx import matplotlib.pyplot as plt # 优化后的布局函数 def refined_concentric_layout_final_adjustment(G, sizes, scale=3.5): pos = {} sorted_nodes = sorted(G.nodes, key=lambda n: sizes[n], reverse=True) num_layers = int(np.ceil(np.sqrt(len(sorted_nodes)))) layer = 1...
a57f93eb71822d59e1034ebcd0d0deb4ef7f1f7cdfe9f10819b68ddfd09a0df9
Python
5,915
148
## Nhat Duong & J Shapiro ## 2019 - 2020 # Imports in the pep8 order https://www.python.org/dev/peps/pep-0008/#imports # Standard library import argparse import subprocess import sys import os # Related third party import numpy as np import pandas as pd ## Define the extensions MANTA_EXT = '.manta' CNVKIT_EXT = '.c...
ec6e50b29f16a3481602f0d8c03ddb6fe1462cd14346bbffcd221744c1d8239c
Python
5,917
169
"""Theme helpers for the MEA-NAP GUI.""" from __future__ import annotations import qdarktheme from PyQt6.QtGui import QFont from PyQt6.QtWidgets import QApplication # Accent colour used throughout the UI ACCENT = "#4f8ef7" # Extra QSS layered on top of qdarktheme _EXTRA_QSS = f""" /* ── Toolbar ────────────────────...
c0e5675f65779ce21ffd7bc8f59e87d0ececf4cd742b10b7ec481c0abb558a11
Python
5,919
161
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved """ Adapted from: 1. https://github.com/meta-llama/codellama/blob/main/llama/model.py 2. https://github.com/naver-ai/rope-vit 3. https://github.com/lucidrains/rotary-embedding-torch """ from typing import Optional import torch from einops impor...
c3c6f77cbbc771e6a5c7a33e4f07387f8106a4b2354b6efbd54156d15c716a3d
Python
5,919
188
#!/usr/bin/env python3 # -*- coding: utf-8 -*- ''' Adapted from: https://github.com/imoken1122/GIST-feature-extractor/ ''' import numpy as np import numpy.matlib as nm import numpy.fft as f class LMgist: """ Class to extract GIST features from images. """ def __init__(self, param, img_size_wh=None): ...
f5c163ba92b1c964f6cd57230f310032857c8c3be214907ab22c2ef620e557f1
Python
5,919
164
import warnings from typing import Optional, Tuple, Union import numpy as np import torch from torch import Tensor from torch.utils.dlpack import from_dlpack def map_index( src: Tensor, index: Tensor, max_index: Optional[Union[int, Tensor]] = None, inclusive: bool = False, ) -> Tuple[Tensor, Optional...
4698ef01ce4225d3eddb965113774ea3861001a51031656364415dd03049f7b5
Python
5,920
161
''' CH4OH ''' import numpy as np import sys def intro(): print(""" SHORT List of potential energy surfaces for CH4OH: 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...
5de3239a92ddc807b0e05e6940454d2831ef4934ee0c754f8522902aaf783b0a
Python
5,920
124
import os from importlib import import_module from pathlib import Path cell_graph_config = { "cell_f_list": [ 'area', 'r_equiv', 'r_maj', 'r_min', 'angel', 'ecc', 'maj_x', 'maj_y', 'min_x', 'min_y', 'x', 'y' ], ...
7df9e58e57fcec5692cfb7c46cfd1b8d098b4cad8b0579e8c5d596fa7795b9ea
Python
5,920
166
"""Spike Time Tiling Coefficient (STTC), port of ``get_sttc.m`` / ``sttc_m.m``. Reference: Cutts & Eglen (2014), "Detecting Pairwise Correlations in Spike Trains: An Objective Comparison of Methods and Application to the Study of Retinal Waves", https://www.ncbi.nlm.nih.gov/pubmed/25339742 """ from __future__ import ...
46a2505f60570f5b17d8b99727dfbfc55f09041df0d21f3240008ebc374b7a49
Python
5,921
159
""" Dataset registry for Pose-JEPA pretraining. Resolves dataset paths from $KINESCOPE_DATA_DIR (default: ~/kinescope_data/). Actual directory layout at /home/msegado/tapedeck/msegado/Datasets/pretraining/ (set KINESCOPE_DATA_DIR to this path): pretraining/ ├── AMASS/ → dataset name "...
1cd1390318faf629eaeb54a6fcf5d264a61a5912ea5424dc182381735b45d434
Python
5,922
125
import pandas as pd import numpy as np from typing import Optional, Union, List from sklearn.base import BaseEstimator as SKLearnBaseEstimator from .survival_utils import get_person_time_df, safe_join, compute_survival_from_single_hazard_curve, \ get_regression_predict_data from causallib.estimation.standardization...
5ce17030315b05ff503d996bafefd27dcef1342fed75ae72227d760f879eac95
Python
5,925
147
# -*- coding: utf-8 -*- """ Created on Thu Oct 19 16:28:37 2023 @author: lcmmichielsen """ import copy as cp import numpy as np from tqdm.notebook import tqdm from sklearn.metrics import mean_squared_error as mse def mse_peaks(RBP, exons_info, peaks, PSI_glia, PSI_neur): rng = 400 bins = 50 ...
c76565a9aeb01422a12f533409bb235a430acebc8188f45430c7c7ee2646decb
Python
5,925
169
import torch.nn as nn from torch.autograd import Variable import torch class ConvLSTMCell(nn.Module): def __init__(self, input_size, input_dim, hidden_dim, kernel_size, bias): """ Initialize ConvLSTM cell. Parameters ---------- input_size: (int, int) H...
e9218bfcf73337baf1bdfddd4cab6cb20632d86e2bb5cd93f597cb1f3adb2317
Python
5,925
153
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license import os import shutil import sys from pathlib import Path import numpy.testing # noqa: F401 # Pre-import before any test can corrupt numpy via in-place upgrade import pytest @pytest.fixture(scope="session") def solution_assets(): """Return ...
b782ebf73804aeddf6a8072ae3ea0239f1bcc608b1d5b44233f9f6080eb309ce
Python
5,927
164
'''Create figures for results of classification_pairwise''' from __future__ import print_function import os import pickle import numpy as np import pandas as pd import scipy.stats as st import matplotlib.pyplot as plt import bdpy.fig as bfig import god_config as config # Main ###################################...
cc0cd3230f8604f5c3972b269518e647860c246f288b570ed9e0eabf5c1a0d7a
Python
5,927
178
""" This class overlays points on top of the image stacks. """ import numpy as np from PyQt5 import QtGui, QtCore, QtWidgets from matplotlib import cm from numpy import linspace from lasagna.ingredients.lasagna_ingredient import lasagna_ingredient from lasagna.utils import preferences class sparsepoints(lasagna_in...
03cf4510dd3a54e2a6e66604b0d294fb1104e08f671f850dd7140d6514a8c262
Python
5,928
124
import os from importlib import import_module from pathlib import Path cell_graph_config = { "cell_f_list": [ 'area', 'r_equiv', 'r_maj', 'r_min', 'angel', 'ecc', 'maj_x', 'maj_y', 'min_x', 'min_y', 'x', 'y' ], ...
18fd4584df2f05361daf1a5ac72e2a8d01e3849db4f5c0ddd43cac46991ccf1d
Python
5,928
143
# coding: utf-8 from pathlib import Path import numpy as np from sklearn.datasets import load_svmlight_file import lightgbm as lgb EXAMPLES_DIR = Path(__file__).absolute().parents[2] / "examples" class FileLoader: def __init__(self, directory, prefix, config_file="train.conf"): self.directory = directo...
7e43401a515fbb5961a46834add46c07c3d5809ba6ea973019ada2f9f45a7915
Python
5,928
124
import os from importlib import import_module from pathlib import Path cell_graph_config = { "cell_f_list": [ 'area', 'r_equiv', 'r_maj', 'r_min', 'angel', 'ecc', 'maj_x', 'maj_y', 'min_x', 'min_y', 'x', 'y', ], ...
ca661e7b829c0fd9a600a74c5199dfba5384b5d87a116ac5eb0b5f2481a6ed88
Python
5,928
149
from typing import Optional, Tuple, List, Callable, Dict, Any import os from glob import glob from torch.utils.data import DataLoader, Dataset from pytorch_lightning import LightningDataModule import albumentations as A import cv2 import pli_transforms.augmentations as aug from pli_transforms.augmentations.pytorch im...
170f0eb066927e1bfd772634743b934a753efeca11e4b174ec22905fa9b81e69
Python
5,931
163
# 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 Optional import math import torch import torch.nn as nn import torch.nn.functional as F fro...
c7e64b840f4d10da8535024700491f53e16a9e8f9f37deb1f1a5e77be3482ae4
Python
5,932
197
""" Generate final data specification for human kidney data with both polygon and semantic annotations. This script creates a data specification JSON file that maps polygon annotation data to the appropriate train/val/test splits while avoiding duplicates from semantic annotations. """ import json import os from path...
38ae4fadb2c1b10d8ea9ee0f878c77ff99e5efe0cc3d626ee6e5c082a22c3f65
Python
5,933
119
#!/usr/bin/env python3 # Author: Francois Aguet import numpy as np import pandas as pd import gzip import subprocess import scipy.stats as stats import argparse import os import qtl.io import qtl.norm def prepare_expression(counts_df, tpm_df, sample_frac_threshold=0.2, count_threshold=6, tpm_t...
a079c2dd6535e7f774948130c7070b6d1644da09b1c0018b5b6596ea80a1b603
Python
5,935
111
import functools import torch from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper from PIL import Image import numpy as np import timm import torch.nn as nn from albumentations import ( Compose, Normalize, Resize, CenterCrop ) from albumentations.pytorch import ToTensorV2 from brainscore_...
bc44291892abe461d52681ef130a1825143396af3e2138d421ef28a149757e68
Python
5,935
154
import sh from scipy import ndimage from warnings import warn from sklearn.metrics import roc_curve import datajoint as dj from . import rf, trippy import numpy as np from matplotlib import pyplot as plt import seaborn as sns from pprint import pprint import pandas as pd import os try: import c2s except: warn(...
97acb028c6a3d1ccece1280bf131c287cfeee4d8499fec1a3715e23f3138c5ce
Python
5,936
171
import os import re import sys import glob import json import numpy as np import os.path as op from os.path import join as ospj import matplotlib.pyplot as plt import nibabel as nib from dipy.io.image import load_nifti from dipy.io.streamline import load_trk from dipy.data import fetch_bundle_atlas_hcp842, get_bundle_a...
c13685105129caa60ce11efb178dab43f6d3ec9131cb1bd7b18ed0339cc31fc5
Python
5,936
175
import copy import numpy as np import torch from ..distances import CosineSimilarity from . import common_functions as c_f class MatchFinder: def __init__(self, distance, threshold=None): self.distance = distance self.threshold = threshold def operate_on_emb(self, input_func, query_emb, ref...
3aea0a8d58b8d09db3984ca767339481c056cbab4e9ce689d8b61654c950c418
Python
5,938
202
import torch, torch.nn as nn, torch.utils.data as data, torchvision as tv, torch.nn.functional as F import pytorch_lightning as L import numpy as np from torch.utils.data import Dataset, DataLoader from sklearn.metrics import roc_auc_score from pytorch_lightning.callbacks import ModelCheckpoint class modulerNetwork2...
576cfd29b315412332cbd571f4a096476259cc869589ca0b9a646d8029aee230
Python
5,938
138
import pytest import numpy as np from brainscore_vision import load_dataset # --- 8-subject surface assemblies --- @pytest.mark.private_access class TestAllen2022fmriSurfaceAssemblies8Subj: def test_train_assembly_shape(self): assembly = load_dataset("Allen2022_fmri_surface_train") assert assemb...
678950b8b756878afe7aa4f928f3b93c15a8a0d1a50fee60cc6185d5bbc597c8
Python
5,939
176
# -*- coding: utf-8 -*- """Visual field sign utilities.""" import datetime import os import shutil as sh import nibabel as nb import numpy as np from .. import execute_command from ..surface.filter import mris_fwhm __all__ = ["get_vfs", "get_weighted_vfs"] def get_vfs( input_sphere, input_white, input...
6f422b6396de11923ee4df4bdbfc5908e15fd25210f88125c437af5985026c7b
Python
5,940
132
import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns #----------------------------------------------------------------------------------- def Plot_Energy_Ranking_TopN(path_read_info_ALLState:str, TopN:int, tick_params_size:int=20, path_save=False) -> None: #----------------...
7b96615ad494cec90606ee0b5be682a8a533e260a22607db6bd3302e5ae4f73c
Python
5,940
150
"""Uses LRP to generate attributions for a VGG16 model trained on CIFAR-10.""" # pylint: disable=duplicate-code import argparse import h5py import numpy import torch from torchvision import transforms from torchvision.datasets import CIFAR10 from torchvision.models import vgg16 from zennit.attribution import Gradie...
c5401de8b45a94ced5c267898dd56171c0bb3e1bb0fe8dc7a997d5c56db98ac4
Python
5,940
158
import pandas as pd import torch as th import numpy as np import dgl def get_data(df, features_dict, terms_dict, features_length, features_column): """ Converts dataframe file with protein information and returns PyTorch tensors """ data = th.zeros((len(df), features_length), dtype=th.float32) ...
2312c7b79e99a29a046dd72ad28943b2092c88c5eb07c00320858ca4e2ff14e3
Python
5,942
200
""" This script performs the ROC analysis for the single-unit data. """ import os import sys import numpy as np import json import pandas as pd from utils.get_session_info import load_subject_names, find_sessions_nested from utils.stat_roc_window import roc_analysis from utils.LoadSession import load_data_for_session ...
257e063ff70dd6a598a23bcb0e299438e3a18fd9d550170bcc9eba95d1f18bce
Python
5,942
106
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/media/lg/disk2/PycharmProjects/ISAT_with_segment_anything/ISAT/ui/anno_dock.ui' # # Created by: PyQt5 UI code generator 5.15.10 # # WARNING: Any manual changes made to this file will be lost when pyuic5 is # run again. Do not edit this fil...
429d409ca5ac89d1ea4947facf09d0442a6bb7ab6bc8d17e9ba0a817807e9142
Python
5,943
158
"""Streamline geometry, against analytically known cases. Every depth calculation in the package is built on this class, so the cases here are chosen so the right answer can be worked out by hand: a 3-4-5 triangle, an axis-aligned path, a point whose perpendicular offset is exact. """ import numpy as np import pytest...
5555e288ec67ff2cad6dc47991a7775d0acad63406fb7906f790bcacc761aac5
Python
5,943
155
import numpy as np import pytest from brainscore_vision import load_dataset, load_stimulus_set from brainscore_vision.benchmark_helpers import check_standard_format # testing stimulus sets @pytest.mark.private_access class TestStimulusSets: # test stimulus_set data: @pytest.mark.parametrize('identifier', [ ...
cfa8f5c6402a627e4827a30fc34bcdd43ae4f117d5cf2c4b3fe43daea6d1d280
Python
5,943
149
# Copyright 2024 Image Analysis Lab, German Center for Neurodegenerative Diseases (DZNE), Bonn # # 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...
130a93b18a6075a84b0b596033bb2962780df8f6845d9b16811b385ce3bab4b7
Python
5,944
185
# 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 # https://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the...
44868fb792a3bd95efe17955cbcc9ec57828b2357d89890c1ae8b380a0601750
Python
5,944
159
""" Base system MB Vessies """ import pytorch_lightning as pl import torch.optim as optim from typing import List from torchmetrics import MetricCollection import re import torch class BaseSystem(pl.LightningModule): def __init__( self, loss : object, lr: float, train_metrics : MetricCol...
055b3b426f7a2c4985025fe24e87513d651f544e8bb5dc0880118fb25e4a82d3
Python
5,945
133
# Created by David Coggan on 2024 06 25 import numpy as np from brainscore_core.supported_data_standards.brainio.assemblies import DataAssembly, BehavioralAssembly from brainscore_vision import load_stimulus_set, load_dataset from brainscore_vision.benchmarks import BenchmarkBase from brainscore_vision.benchmark_helpe...
405f5ca0ea21585c769f432a5b6d25c264bf8c754b6ea8ad3566ea2c34b06813
Python
5,948
141
############################################################################# # Copyright (C) 2020-2026 MEmilio # # Authors: # # Contact: Martin J. Kuehn <Martin.Kuehn@DLR.de> # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may...
978e79b177e67f3f5b32de43edefdcb4090b59589ed3386d16e32a08594b7c3f
Python
5,948
163
#!/usr/bin/env python # author: Jannes Spangenberg # e-mail: jannes.spangenberg@uni-jena.de # github: https://github.com/JannesSP # website: https://jannessp.github.io from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, Namespace import os import csv from pathlib import Path from collections import def...
98d59385b13711d00f9249ea31297062b349b22c141d8785e1aad974fa14daa7
Python
5,948
136
import torch from torch import Tensor from typing import List, Tuple, Optional, Union import torch.nn as nn from .layer_norm import LayerNorm from .drop_path import DropPath class Block3D(nn.Module): r""" ConvNeXt Block. There are two equivalent implementations: (1) DwConv -> LayerNorm (channels_first) -> 1x1...
65729b83cdd82fbc316c341ce941350a1ab7d506ac3fe6380587b37fa35678ff
Python
5,950
156
# Required libraries import matplotlib matplotlib.use('Agg') # Set globally for all matplotlib usage import glob import os import torch import glob import os import torch import numpy as np import random import matplotlib.pyplot as plt from skimage.transform import resize from torch.utils.data import Dataset from mon...
964b370c7dfb2b155e80201ae394d61842fbf37f0bca44b6c6c2a0723e63a273
Python
5,951
166
# Created by David Coggan on 2024 06 23 # package stimuli from brainscore_core.supported_data_standards.brainio.stimuli import StimulusSet from brainscore_core.supported_data_standards.brainio.packaging import package_stimulus_set, package_data_assembly from brainscore_core.supported_data_standards.brainio.assemblies ...
34541825ea32135a6b6c3b62ac78754f40bbec810d90398a8e4bcfaebd4cf4f8
Python
5,953
155
import os import os.path as osp import shutil from ogb.utils import smiles2graph from ogb.utils.torch_util import replace_numpy_with_torchtensor from ogb.utils.url import decide_download, download_url, extract_zip import pandas as pd import numpy as np from dgl.data.utils import load_graphs, save_graphs, Subset import ...
516ad2fffc7edc231541d754ab6e3899b2920e03593ed121ff758234937b3697
Python
5,953
112
"""Prompts for the OCSR tool. Two distinct kinds of prompt, easy to confuse: 1. :data:`OCSR_SYSTEM_PROMPT` and :data:`OCSR_USER_PROMPT` go *inside* the tool, to the vision model, and are vendored verbatim (see below). :data:`OCSR_STRUCTURED_SYSTEM_PROMPT` replaces the first of those when the caller asks for ...
58acc1db50c9a634e89e1c5fa94539ec464f511e54de691f42d046ac27a77057
Python
5,953
147
import os from nipype.interfaces.base import BaseInterface, BaseInterfaceInputSpec, TraitedSpec, File, Directory, traits, CommandLineInputSpec, File, TraitedSpec, CommandLine, Directory import csv import numpy as np class TckSampleInputSpec(CommandLineInputSpec): tracks = File(desc="Path to the input tck file", ma...
99c1a38cef734ce441f250789e2a3b1262ac2266ef6471e079622ea9319f593b
Python
5,953
161
import unittest import pandas as pd from causallib.model_selection import TreatmentOutcomeStratifiedKFold from causallib.model_selection import TreatmentStratifiedKFold class TestTreatmentOutcomeStratifiedKFold(unittest.TestCase): def test_binary_splits(self): X = pd.DataFrame({0: [10] * 8}) # Dummy cor...
fa307eb98a18aa4d108d2b4085a79cdf4bb21005a9eb837debf070df7a18f07f
Python
5,958
134
""" Lambda Layer Paper: `LambdaNetworks: Modeling Long-Range Interactions Without Attention` - https://arxiv.org/abs/2102.08602 @misc{2102.08602, Author = {Irwan Bello}, Title = {LambdaNetworks: Modeling Long-Range Interactions Without Attention}, Year = {2021}, } Status: This impl is a WIP. Code snippets in the...
8586bbce07f07b492b91b89ef92b0a03b8edc1e7404e3a7ff72a6de2b8a46321
Python
5,959
174
#!/usr/bin/env python3 """ Window Size Optimization Script Runs the end-to-end pipeline for several window sizes using non-overlapping windows. Summaries are reported per window to support method selection. Authors: Evans Nyanney, Parthasarathy D Thirumala, Shyam Visweswaran, Zhaohui Geng Year: 2025 License: MIT """ ...
2845d258adbcf765524f3114bca4951aa805eea08c7dc731ef97a4d72479b208
Python
5,961
180
from typing import Optional, Union, Dict import os import shutil import os.path as osp import torch import numpy as np from ogb.utils.url import decide_download, download_url, extract_zip, makedirs class MAG240MDataset(object): version = 1 # Old url hosted at Stanford # url = 'http://ogb-data.stanford....
ef45e6293da0226395a433fc5ead7a33af64dcf837a84d1172de9c7929088d03
Python
5,963
170
"""Read-only package resources exposed through the Deep Agents file protocol.""" from importlib import resources from pathlib import PurePosixPath from deepagents.backends.protocol import ( BackendProtocol, DeleteResult, EditResult, FileDownloadResponse, FileUploadResponse, GlobResult, LsR...
27aa09ebccaf2461aeddade185bf74ed8075897086f55ca94a9c3ff24c13e31e
Python
5,966
204
import os import json import time from datetime import datetime import numpy as np CACHE_VERSION = 2 def _finite_float(value, default=0.0): try: number = float(value) except (TypeError, ValueError): return float(default) return number if np.isfinite(number) else float(default) def _to_...
2eb3a93c5a544655e65e73c2082d1273cc050f440b75181e1a76b443a476a6b6
Python
5,966
177
import json import argparse from chemgraph.tools.ase_tools import run_ase from chemgraph.tools.cheminformatics_tools import smiles_to_atomsdata from chemgraph.models.ase_input import ASEInputSchema import datetime import subprocess def get_atomsdata_from_smiles(smiles: str) -> dict: """Return a workflow of conver...
ffa7abd1f73c52ac786d8073da1bb386de4dd38d557a558e38e134291cc4da6a
Python
5,969
131
#!/usr/bin/env python # coding: utf-8 ''' Dependencies: pip install numpy pandas chmod +x script.py In this code we loop through all MERFISH cells and add a new metadata to them: their region information and its estimated volume in the slice. So if a cell sits in the MOB we calculate the intersected volume of the MO...
1e89e913b79660ac1c8870c8d494adc23ee9f591e90c14d53ec6587e6ce18ade
Python
5,970
158
# -*- 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 torch import torch.nn as nn from torch.nn import functional as F from typing import Tuple ...
e928132f2221c0630e59d3bf073efba97c2d05252d0eddb0d283f105137f4956
Python
5,970
194
import pandas as pd import numpy as np import argparse import matplotlib.pyplot as plt parser = argparse.ArgumentParser(description='Preprocess edge list') parser.add_argument('-e','--edge_list', help='Edge List to be processed.', required=True) parser.add_argument('-n','--node_list', help='Node List to be processed.'...
f23c62e5716c34e0546ce6387cbf06cd902cfd296ca820be08e4f9ce13d4fe81
Python
5,971
170
import numpy as np from meanap.params import Params from meanap.pipeline.burst_detection import burst_detect_network, single_channel_burst_detection def firing_rates_bursts( spike_times_dict: dict[int, np.ndarray], n_channels: int, fs: float, duration_s: float, params: Params ) -> dict: """Ca...
41e25c2c2f27b8328d766bd42531a7b36da8b60f8ae137dfddfde1a5632616d1
Python
5,973
157
import math import os import torch import torch.nn as nn import torch.utils.model_zoo as model_zoo BatchNorm2d = nn.BatchNorm2d def conv_bn(inp, oup, stride): return nn.Sequential( nn.Conv2d(inp, oup, 3, stride, 1, bias=False), BatchNorm2d(oup), nn.ReLU6(inplace=True) ) def conv_1x1_...
b3b59b9b85ec568759cd1a8cf79500d85d73efa2ed2f7c213e59ec16a040fe4e
Python
5,973
132
import re import torch import torch.nn as nn import torch.nn.functional as F from collections import OrderedDict class _DenseLayer(nn.Sequential): def __init__(self, num_input_features, growth_rate, bn_size, drop_rate): super(_DenseLayer, self).__init__() self.add_module('norm1', nn.BatchNorm2d(num...
1fe6e9e65633a6398499e27fa470cc532d6461c72de1e5680f3cc4f1ecbb84cf
Python
5,975
181
from pathlib import Path from typing import List import sys sys.path.append('.') import hydra import numpy as np import torch import omegaconf import pytorch_lightning as pl from hydra.core.hydra_config import HydraConfig from omegaconf import DictConfig, OmegaConf from pytorch_lightning import seed_everything, Callbac...
886a5ead30d2c3773b51ba81da2e695d103ce8c466dd9441adc7bb8075aba5aa
Python
5,978
194
# -*- coding: utf-8 -*- import logging import numpy as np from numpy.linalg import norm from scipy.spatial import cKDTree from scipy.sparse import bsr_matrix def _subdivide_streamline(streamline, n_steps): if n_steps < 2: return streamline dirs = streamline[1:] - streamline[:-1] subdivided = np....
fd8cf8b3a49aff6b192e71a4e4775d096bc10479c8966887d6dad11953749f4b
Python
5,978
152
#!/usr/bin/env python3 """merge_csv_columns.py Copy columns AxL_mean, AxL_diff, SphEq_mean, SphEq_diff **from** ``data/Data_M1D6_Preproc.csv`` **to** ``data/Data_M1D5_Preproc.csv`` by default, inserting them immediately before the column ``MRRsOD_Binary``. You can still override the paths from the command line, but i...
0b4e303554a4751a27b99319cfa09f066e40c8db964571ae37a3efcd4d6836fb
Python
5,979
224
# -*- coding: utf-8 -*- """FSL registration algorithms.""" import os from .. import execute_command from ..io.filename import get_filename __all__ = [ "flirt", "apply_warp", "apply_flirt", "convert_warp", "combine_warp", "apply_fugue", ] def flirt( file_in, file_ref, file_out, ...
0dc502982a4c11902ba5ed274a6a71fe407dcbc6c1ae22c4f15ad1854bcd0494
Python
5,979
131
from scipy.io import loadmat from scipy import sparse import os import time import numpy as np import sys import argparse def argument_parse(): parser=argparse.ArgumentParser() parser.add_argument('--chunklist',action='store', dest='chunklist', required=True) parser.add_argument('--fileroot',action='store', dest='...
0fb0a935be579f52bd1c0450948c603b184d67d7cf893c82841a985d1d639fba
Python
5,979
161
import json import shutil from functools import cached_property from pathlib import Path from typing import TYPE_CHECKING, Optional, Tuple import numpy as np from huggingface_hub import HfApi, hf_hub_download from brainways.model.model_utils import load_model from brainways.pipeline.brainways_params import AtlasRegis...
292055f5605898c9481c3d527ace0ce4a4f06126608cfcbf538116bfec2b247f
Python
5,980
107
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/media/lg/disk2/PycharmProjects/ISAT_with_segment_anything/ISAT/ui/process_exif_dialog.ui' # # Created by: PyQt5 UI code generator 5.15.10 # # WARNING: Any manual changes made to this file will be lost when pyuic5 is # run again. Do not edi...
005dc8642e51b3f207a0e5323e59e7bcfd1c08144e530cb0caf09990ec4fa9f8
Python
5,981
218
#!/usr/bin/python3 # import os import sys import argparse import numpy as np from sklearn.neighbors import NearestNeighbors from uac import utils # Create the parser my_parser = argparse.ArgumentParser(description="Calculation of labels using laplace solves only") # Add the arguments my_parser.add_argument("target_p...
00797cbbe3d5ff4bf0dffdd25a5ec9ce8d2e098ebc5c472ea733965608535241
Python
5,981
166
import ijson from pathlib import Path import torch import numpy as np import time import csv import statistics from urlextract import URLExtract from transformers import ( pipeline, BertTokenizerFast, BertModel, ) import pandas as pd root_dir = Path.cwd().parent.parent.parent dataset_dir = root_dir / 'data...
f9dab4adf30fdb4ffb8d33be59c06cf4170ab725c90aebff3cd42049d08aa1ab
Python
5,982
141
from brainscore_vision.model_helpers.check_submission import check_models import functools import numpy as np import torch from transformers import AutoImageProcessor, ConvNextV2ForImageClassification from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper from PIL import Image from brains...
e6195e139739d57ab49d23ff3f245bafeba433edca45139d2eb48d85ce00397d
Python
5,983
142
from typing import Optional import torch.nn.functional as F from torch import Tensor from torch_geometric.nn.conv import MessagePassing from torch_geometric.nn.conv.gcn_conv import gcn_norm from torch_geometric.typing import Adj, OptPairTensor, OptTensor, SparseTensor from torch_geometric.utils import is_torch_sparse...
151cb12eddab44b302e0229fb9445e6f3b65caeacc88ad7c112c60961a9f2e7e
Python
5,984
140
""" General functions for preprocessing IVIM image data. """ import numpy as np import nibabel as nib from ivim.io.base import data_from_file, file_from_data, read_bval, read_bvec, read_cval, read_im, write_bval, write_cval, write_bvec def average(im_file: str, bval_file: str, outbase: str, cval_file: str | None = No...
fd0f59260af4e70d39d3bc3e36d6063eaa9cc1e32e0b6a2d3f03503d081a25df
Python
5,984
152
from ..qt import * import logging LOGGER = logging.getLogger(__name__) class DistortionTextEdit(QTextEdit): def __init__(self): super().__init__() self.on_apply = lambda: None def focusOutEvent(self, e): self.on_apply() def keyPressEvent(self, e: QKeyEvent): if e.key() == Qt.Key.Key_Return an...
8a99f1d6e7a9bfd65cc7a7ebabf226fa1a6c6549305b4f2b4453e195252a3f18
Python
5,985
127
#!/bin/python """ python Py_write_dPCA_min_max.py all.txt #seq #time_segment #clean python Py_write_dPCA_min_max.py all.txt GVAAA 50-100ns 0.05 Created by Diana Slough Created on 1-5-2017 This program reads all.txt (from dPCA) and writes the driver files for s1 and s2 """ import sys,os import numpy as np import mat...
af556d126deef00f3aab1e0578371fe9ab6fc42e371ff80a14c7d3c340aeca6b
Python
5,985
153
import pandas as pd import os from multiprocessing import Pool import sys import numpy as np def mpl_writer(patch): patch_name = patch[0] output_path = patch[1] patch_meta = patch[2] patch_cts = patch[3] patch_f = patch[4] print('Processing subsample {}'.format(patch_name)) patch_cts.to_csv...
0c50fc6c114833700b1ddb2e28db70224620680dfc116d3ae98b19027e349ca1
Python
5,986
181
import argparse import torch import torch.nn.functional as F from torch_geometric.data import Data import torch_geometric.transforms as T from torch_geometric.nn import GCNConv, SAGEConv from ogb.nodeproppred import PygNodePropPredDataset, Evaluator from logger import Logger class GCN(torch.nn.Module): def __...
25e657fc88fe9d5719aed5ccaf2df41236116cadcba9c59d3102d3f9549754a1
Python
5,988
185
#!/usr/bin/python # ## @file # # This handles one or more feed viewers. These are similar to camera # display(s) except that they can only view the feeds. # from PyQt5 import QtCore, QtGui, QtWidgets # Debugging import storm_control.sc_library.hdebug as hdebug import storm_control.hal4000.display.cameraFrameDisplay ...
8310f144840a4c65f9153268fe9294bf07770ddc056a448dfacd0208872c2b1e
Python
5,988
216
# -*- coding: utf-8 -*- # python standard library inputs import os from pathlib import Path # external inputs import numpy as np import h5py from nibabel.freesurfer.mghformat import MGHHeader # local input from .surf import write_mgh from .get_filename import get_filename __all__ = ["read_hdf5", "write_hdf5", "extr...
0fd0961d74dcca9e49d947edc15192259ad6a2e63ee2e5d9a811fec1a4c824a7
Python
5,989
157
import os from copy import deepcopy import numpy as np import argparse import innvestigate.utils as iutils from keras.models import Model from keras.preprocessing import image from keras.utils import to_categorical import keras import tensorflow as tf from numpy import average, dot, linalg from utils import * from lrp ...
5814912cf1e92b35e871757837588d27892dc968e3054b86ecbefb280ddfe88f
Python
5,989
253
import numpy as np import pytest import seisbench.generate as sbg @pytest.fixture def record(): return np.zeros((100, 4), dtype=np.float32) @pytest.fixture def metadata(): return { "__annotations__": { "P": np.array([50, 50, 50, 50], dtype=float), } } # -------------------...
b8eeb15be8835d1caf6bf97cb7b86c78a1678237741f00f72c54caaf6937ce9e
Python
5,989
217
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved """ Utilities for bounding box manipulation and GIoU. """ from typing import Tuple import torch def box_cxcywh_to_xyxy(x): x_c, y_c, w, h = x.unbind(-1) b = [(x_c - 0.5 * w), (y_c - 0.5 * h), (x_c + 0.5 * w), (y_c + 0.5 * h)] retur...
2a189e0f31d26bee3989159b30db347dd5bf2ecb0bc9fb48d0dc9adad31ebaa0
Python
5,990
173
from itertools import product from typing import Dict, List, Optional import numpy as np import pandas as pd from brainways.utils.atlas.brainways_atlas import BrainwaysAtlas from brainways.utils.cells import get_parent_struct_ids def set_co_labelling_product(cells: pd.DataFrame): label_columns = [c for c in cel...
ec18495d7cdeb43d3173ae72b2a31d4f899f6364f967c67fb6d316451b45b174
Python
5,993
122
from detectron2.utils.logger import setup_logger setup_logger() import numpy as np from detectron2 import model_zoo from detectron2.config import get_cfg import logging import os import detectron2.utils.comm as comm from detectron2.checkpoint import DetectionCheckpointer, PeriodicCheckpointer from detectron2.data impor...
97e1ff4b6ca2f88850b54ff008fa1f29c4da153d39244a42209027081fb90ac5
Python
5,994
126
import numpy as np from GEASO.utils.utils import voxel_data from GEASO.utils.utils import normalize_coords from GEASO.utils.utils import cal_distance def inlier_from_NN(x, y, distance, max_iter=100, gamma=0.5, scale_c=False): # x: source coordinates, shape (N, D) # y: target coordinates, shape (N, D) N, D...
ee9ef6f4e66b7eed25d0eed2b29f5680c562882fdfa2494a94dc52c80c7666ca
Python
5,995
166
import sys from pathlib import Path p_dir = str(Path(__file__).absolute().parents[2]) if p_dir not in sys.path: sys.path.insert(0, p_dir) import os import argparse import json from datetime import datetime import tempfile import shutil from environs import Env from jinja2 import Environment, FileSystemLoader, select_...