sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
383f00ca13affadabb18824f407d11cee9d0838ebf9c3079eb3b4361db20d5c7
Python
4,951
145
# Copyright 2024 Google LLC # # 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, ...
5fed56f071fab72c26b732c5341fc53add457fb95f0e49c8417bff431a6feb27
Python
4,952
117
#!/usr/bin/env python3 # tools/export_optuna_trials.py import json from pathlib import Path import optuna import pandas as pd def main(): # 1. 结果目录 results_dir = Path("results") results_dir.mkdir(exist_ok=True) # 2. 加载回归模型的 Optuna Study study = optuna.load_study( study_name="opt_reg", ...
b18a5fb985b0c31cef38eded2b34d5af41920abe413494373ba215f1a38d2571
Python
4,952
114
import nibabel as nb import numpy as np import subprocess import os import glob from scipy.ndimage import morphology root = '/media/sebastian/Data/S1ANFUNCO/raw_data/S1ANFUNCO_BIDS' subs = ['sub-05'] for sub in subs: # first, we have to inflate our ROIs # Load nii = nb.load(f'/home/sebastian/Desktop/pat...
e1ec10c4629ed372e51bef96f74b83db3bd90ec55a2fdc7bf1351de1e6cfeac9
Python
4,952
125
import matplotlib from numpy import loadtxt from fig import module_utility import scipy import random import numpy as np import matplotlib.pyplot as plt from pathlib import Path sub_group = list(range(1, 29)) sub_group.extend([30, 32,33,34,35]) # exp data num_subject = len(sub_group) angle_colume = 19 # col20 subj1...
e4882ebee6937743aaafa0728984333faa3f070704cc31a399a69de59ee404fc
Python
4,952
154
############################################################################# ### Recursively moves through directories and extracts parameters and the ### ### mean firing rates of neuronal subpopulations ### ############################################################################# ### Cop...
62249eb1d94b0f293c3227aaad2d5651222d7b637ed6f011fbb6b61fa41d204a
Python
4,954
116
""" Adapted from the NSuite benchmarking framework (https://github.com/arbor-sim/nsuite.git). """ from neuron import h import cell import numpy as np class RingNetwork(object): def __init__(self, params, pc): # Parallelization parameters self.rank_id = int(pc.id()) # host process/rank ID...
fa9bfae8a764aafe826f8e51c99c1533f00495837ee57609ce7d150625921ad4
Python
4,954
152
"""Test pipeline Step 3 — functional connectivity (STTC) parity with MATLAB. Run from the repo root:: uv run python python/test_pipeline_step3.py Two things are validated, since MATLAB's own pipeline only ever persists the *stochastically thresholded* adjacency matrix (never bit-reproducible — see ``probabilisti...
fbf2ecfdf8af94ab5d89871724316b91aca0b795f49481d8e4bb4b1721019e2d
Python
4,954
142
import numpy as np import pandas as pd import json import os import networkx as nx import pickle as pkl from textblob import TextBlob from collections import Counter import torch from sklearn.manifold import TSNE import matplotlib.pyplot as plt from sklearn.cluster import KMeans import matplotlib.colors as col from mat...
00b78274121c5f82acc87d8633e5e696d37465d79e3d50957cb0802aec657dab
Python
4,955
142
# This file is part of Mooney computational modeling project. # # Mooney computational modeling project is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) an...
6a06b21b67eb7d830fd3223f52188f4e18f96752981d37d4393d041c0d9a9576
Python
4,955
167
"""Finetune an SFCN model from a JSON configuration.""" import argparse import json import logging import os from typing import Any import pandas as pd import tensorflow as tf from pyment.configurations import ( CategoricalTargetConfiguration, FinetuningConfiguration, compile_target_encoder, ) from pymen...
fa2140fafbce4e593233329ddfff33d741bd67cea54699bb1693c12ba34649e6
Python
4,957
117
# This file is part of connectome-manipulator. # # SPDX-License-Identifier: Apache-2.0 # Copyright (c) 2024 Blue Brain Project/EPFL """Module to facilitate easier job management""" from contextlib import contextmanager from pathlib import Path from .. import log, utils, profiler class JobTracker: """Class to tr...
31e279489abeaf687e2ea0eedb4a38e50cc5b4491d619a061ef500f950007f45
Python
4,958
125
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved import math from typing import Optional import torch from torch import nn class PositionEmbeddingSine(nn.Module): """ This is a more standard version of the position embedding, very similar to the one used by the Attention is all y...
3be9d2a2a0305c2cd77dc887ea8bbff80b55dc436d6517555ffb73de43d79a4d
Python
4,958
123
############################################################################# ### Recursively moves through directories and extracts parameters and the ### ### mean weights across neuronal subpopulations ### ############################################################################# ### Cop...
66973927f729ab7a765d8bc4f37ba6e67e221efb85742b292c64a886bc283e1f
Python
4,958
101
import pytest pytest.importorskip("fireants_fused_ops") import torch from time import time from torch import nn from torch.nn import functional as F from fireants.interpolator.fused_grid_sample import fused_warp_composer_3d from fireants.interpolator.grid_sample import torch_warp_composer_3d # set seeds seed = 4531 to...
46a07eb2ab66abcbc75c3f0b9d0ef9f59bb884438b1fb17d4a713a0cac3934b1
Python
4,960
146
#%% imports from pathlib import Path from benedict import benedict import re import time import os from deep_events.database.folder_benedict import get_dict, save_dict, set_dict_entry, handle_folder_dict from typing import Union from deep_events.database.convenience import glob_zarr #%% setup MAIN_PATH = benedict(os...
4fbbf2fd466fdf9e7a8143a9ec91c46261d96e4f764445f90fd84e1e8b5f361c
Python
4,960
155
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved import argparse import json import os from collections import defaultdict from iopath.common.file_io import g_pathmgr from sam3.eval.saco_veval_evaluators import ( VideoCGF1Evaluator, VideoPhraseApEvaluator, VideoPhraseHotaEvaluator, ...
9089d55c3bcf424a8fa9c724286a3b239724630ac1ddf073d6983b9c1ebf3d58
Python
4,960
145
from qtpy.QtWidgets import ( QApplication, QGroupBox, QHBoxLayout, QVBoxLayout, QLabel, QLineEdit, QPushButton, QSpinBox, QWidget ) from qtpy.QtCore import QThread, Signal import napari from typing import TYPE_CHECKING if TYPE_CHECKING: import napari from ._input_data_widget import InputD...
217551254fd85cc6725c0144c4e1e4ae67450fc3cf7fc9ebf09870de24cf08be
Python
4,961
139
from __future__ import annotations import dataclasses from typing import Literal from unittest.mock import patch import numpy as np import pytest from PySide6 import QtCore from PySide6 import QtGui from PySide6.QtWidgets import QApplication from labelme._shape import Shape from labelme._widgets import _shape_render...
f84bd32f27d11e503a0cfc6a6bc443a8b140a33556ece2e979ce8fd1172bad6a
Python
4,961
136
from keras.models import Model import numpy as np import innvestigate.utils as iutils import os from keras.preprocessing.image import img_to_array, load_img import tensorflow as tf import PIL.Image import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import cv2 from interpreters import SGLRP, CLRP,...
56b07197718c6635cb2413249340595993714046c8989145fdfbf5efac3a792f
Python
4,963
181
from dataclasses import dataclass from typing import TYPE_CHECKING, Any, ClassVar, Literal, Protocol, Union import numpy as np from eir.models.input.array.models_cnn import CNNModel, CNNModelConfig from eir.models.input.array.models_identity import IdentityModel, IdentityModelConfig from eir.models.input.array.models...
b9bda4db119b89df42b341eb1498b8cf2651c558ff11654b412278fd0b65f2b1
Python
4,963
131
# Copyright 2024 Google LLC # # 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, ...
fc6737e5e85175023014708dc8178e10a507dcb22480c2a996cd4223bba48947
Python
4,963
130
import json import numpy as np import pandas as pd def load_data_from_keys(json_file, key): """ Load data from a nested json file. Json file is opened and iteratively searched for specified key in data. A dictionary is returned containing all matching entries. Args: json_file (str): path to jso...
8d24c9abed731994f5cd15afe41cb206e038950763fc415ca226dd2e3450683a
Python
4,964
117
""" Random Erasing (Cutout) Originally inspired by impl at https://github.com/zhunzhong07/Random-Erasing, Apache 2.0 Copyright Zhun Zhong & Liang Zheng Hacked together by / Copyright 2019, Ross Wightman """ import random import math import torch def _get_pixels(per_pixel, rand_color, patch_size, dtype=torch.float3...
361f62bcc1d74d884515404d6e8695e60ab18af10764cb6d6b3c6d3792cd0d3e
Python
4,966
166
# Copyright (C) CVAT.ai Corporation # # SPDX-License-Identifier: MIT from __future__ import annotations import io import mimetypes from collections.abc import Sequence from pathlib import Path from typing import TYPE_CHECKING from PIL import Image from cvat_sdk.api_client import apis, models from cvat_sdk.core.help...
2f2bc83b996844b9b1f5a5ea898b39afb320207e84f26915f7ae680f00269bf3
Python
4,969
186
""" Penn Action loader: MATLAB label files (.mat) -> normalized COCO-17 clips. Directory layout expected: Penn_Action/ ├── frames/ │ ├── 0001/000001.jpg ... │ └── ... └── labels/ ├── 0001.mat └── ... Each label file contains: x, y : (T, 13) keypoint coordinates vi...
7182d9ca192346a933ab1b25fa3dd71ef2adb3ecc3256e08b19ae25d84227b03
Python
4,971
144
############################################################################### #################### Boilerplate ######################## ############################################################################### import pandas as pd import matplotlib.pyplot as plt import os import matplotlib...
a1e61abc0f1cafe2818a3df0abc2569952544ede7b03f3104e8d92cc80a72810
Python
4,971
164
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Tests for select_optimal_pcs. """ import numpy as np import pytest from pcafeat.pca_feature_select import select_optimal_pcs def test_select_optimal_pcs_basic(): """Select PCs with high target scores and low noise scores.""" target_pcs_lists = [ [(0,...
e005b96ad4fc95fe6a3545622deaea6a78308453614c3bffa7b9ff40d12256aa
Python
4,971
140
from __future__ import annotations import pytest from PySide6 import QtCore from PySide6 import QtGui from PySide6 import QtWidgets from pytestqt.qtbot import QtBot from labelme._widgets._label_dialog import LabelDialog @pytest.mark.parametrize( "modifier", [ QtCore.Qt.KeyboardModifier.NoModifier, ...
e17d660fc79490ffd8ce461a780928f5942d806e3401fc9db09284ac25fe7799
Python
4,971
154
from torch import nn, cat as tcat, tensor, save as tsave, load as tload, no_grad, zeros from torch import normal, rand, exp, log, randn, arange from torch import float32 as tfloat, ones_like from numpy import sqrt, linspace, meshgrid, concatenate, newaxis, polyfit, polyval from matplotlib.colors import TwoSlopeNorm imp...
bcd23d4242789f83419a849f7218032e1b3596c982ba86c800209d3095706b06
Python
4,972
147
import pandas as pd from sys import argv import pickle as pk import os import annotate as ann import optimize_FLAMES as optf def add_into_single_df(list_of_dfs): df = pd.concat(list_of_dfs) df = df.reset_index(drop=True) df["locus"] = pd.factorize(df["filename"])[0] return df def create_XY_train(df, f...
c082c30e1a88db5ad4f3d16a414da00398fd1b6f74749f1f8bcac2a0bea851e3
Python
4,972
135
import numpy as np from argclz import argument, AbstractParser, int_tuple_type, union_type from neuralib.persistence import persistence from neuralib.persistence.cli_persistence import get_options_and_cache from rscvp.spatial.main_cache_occ import ApplyPosBinCache from rscvp.spatial.util import sort_neuron, normalized...
3e1c00b95765a0b7ef2fdcd14946b20bfbbee61fd396c177ecc9ddd06bf700ee
Python
4,973
147
""" Various transformations used for data preprocessing RR van de Leur, MN Bos and MB Vessies """ import torch import numpy as np from scipy import interpolate class ToTensor(object): """ Converts the ECG waveform and label numpy arrays to FloatTensors. """ def __call__(self, sample): wavefo...
01dc4ce33230c638f0b553799159f3d7fe5a1ee5d74b68d5a20d6cba0f405db4
Python
4,974
132
# Copyright (C) CVAT.ai Corporation # # SPDX-License-Identifier: MIT from __future__ import annotations import unittest from types import SimpleNamespace from unittest import mock from rest_framework.exceptions import ValidationError from cvat.apps.quality_control.models import QualityReport, QualityReportTarget fr...
af9f1bc3d342279140f005115fbc3af4b755e8364cf21b8d7ff34376ff3da9a5
Python
4,977
107
import argparse import os import glob import re import subprocess def main(): parser = create_args() args = parser.parse_args() chroms = get_union_chroms(args.datasets) print('combining files from', len(chroms), 'chromosomes over', len(args.datasets), 'datasets...') combine_longs(args.datasets, chr...
244d59daa2549f11deb0e9493160687db59c22b12519f609603d3c3858da7848
Python
4,979
113
"""Train linearizing encoding models using the NSD-core subject-unique image features and fMRI responses, and use them to predict fMRI responses for the: (i) NSD-core ID test images. (i) NSD-core OOD test images. (iii) NSD-synthetic 284 images. Parameters ---------- subject : int Number of the used NSD subject. data_...
b6b13f2af4a07c568b8651190eecf2e7414a39a27a8ff32493788c67cb9d91dc
Python
4,980
131
# Copyright (C) CVAT.ai Corporation # # SPDX-License-Identifier: MIT from django.contrib.auth import get_user_model from django.core import mail from django.test import override_settings from django.urls import reverse from rest_framework import status from cvat.apps.engine.tests.test_rest_api import create_db_users ...
422b66c50d5196d12e87e3aa860cd1cc29524ea596ebb989c43f6b4fb46d1fc5
Python
4,983
141
# %% import torch from torch_geometric.nn import SAGEConv, to_hetero,GeneralConv from torch.nn import Linear import torch.nn.functional as F from sklearn.metrics import roc_auc_score,average_precision_score import numpy as np import random import pandas as pd import itertools SEED = 666 random.seed(SEED) ...
8199415977ea4a4e21710701f15764407f189cbf7cc1c1ec9353f26419f695ad
Python
4,983
134
import os import csv from typing import Tuple import pandas as pd import logging from xnat.mixin import ImageScanData from step1_dataimport.xnatconnectionprovider import XNATConnectionProvider class DataOverview: """ Generates an overview csv-file with DICOM properties and other metadata (subject-, session-, ...
cf3414848a2378cb0fac7bf86039e9bd65d18e6c0594c2e40b219727f45e4ac3
Python
4,983
176
import logging import os import random from collections.abc import Callable, Iterable, Sequence from functools import wraps from pathlib import Path from typing import Any import numpy as np import torch from aislib.misc_utils import ensure_path_exists from eir.train_utils.distributed import ( in_distributed_env,...
ed653f76bfa12adb9e483137face034f5cbad9dec060fffc78ce4e33303dd407
Python
4,983
100
#encoding=utf-8 import sys sys.path.append("../") import jieba def cuttest(test_sent): result = jieba.cut(test_sent,HMM=False) print(" / ".join(result)) if __name__ == "__main__": cuttest("这是一个伸手不见五指的黑夜。我叫孙悟空,我爱北京,我爱Python和C++。") cuttest("我不喜欢日本和服。") cuttest("雷猴回归人间。") cuttest("工信处女干事每月经过下属科...
4ffede7faa7f629959c93d290c4276b9b7705243b0f63f37db97b8545f18e659
Python
4,985
78
import os import sys import json from mako.template import Template sys.path.append(os.path.abspath(os.path.dirname(os.path.realpath(__file__)))) from macularCellGenerator import load_json as load_cell_json from macularSynapseGenerator import load_json as load_synapse_json def load_jsons(json_dir): cells_json_da...
4d8919def3ac7002c7c20a7b0cf201c34020550ad5234c9e4e1b5eb269808988
Python
4,986
86
#!/usr/bin/env python import pandas as pd import numpy as np from PAINTeR import global_vars from PAINTeR import misc from PAINTeR import qst # load tables df_bochum = pd.read_csv(global_vars._BOCHUM_TABLE_) df_essen = pd.read_csv(global_vars._ESSEN_TABLE_) df_szeged = pd.read_csv(global_vars._SZEGED_TABLE_) # calc...
1ef8c1fbee85c4088e2fe2cee774cf5e90ec128e8c99f9409edfa2e37ef060c0
Python
4,990
145
from collections import OrderedDict, namedtuple from pprint import pformat from neuro_data.static_images.data_schemas import StaticScan from neuro_data.static_images.configs import DataConfig from .utils import gitlog, set_seed from . import logger as log import datajoint as dj from .configs import NetworkConfig, Seed,...
337c74296a8aed185d24b85a7e0fca60ef0c8a65f1406ab232d1e3ee10457e42
Python
4,990
134
""" (C) Copyright 2019 IBM Corp. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software ...
86a57cf9c36d408fbabc272925b0e0207d9cb894bb5a397846f1b206681c7e38
Python
4,990
211
""" very simple ini parser and tools tested on python 3.6 contact: adalca at csail.mit.edu TODO: see from collections import namedtuple instead of Struct """ # built-in modules # we'll need python's ini parser: 'configparser' import configparser def ini_to_struct(file): """ very simple ini parser that...
e69500cdb342010319230dbb9869f5661797e4a6eb7341ac277bd7d486da2030
Python
4,990
101
#encoding=utf-8 from __future__ import print_function import sys sys.path.append("../") import jieba def cuttest(test_sent): result = jieba.cut(test_sent,cut_all=True) for word in result: print(word, "/", end=' ') print("") if __name__ == "__main__": cuttest("这是一个伸手不见五指的黑夜。我叫孙悟空,我爱北京,我爱Pytho...
1b7678a2186a6570153df969b6e3a192dc2e71b5b7b60f05c926fb813b41ada1
Python
4,991
128
import numpy as np from impyute.ops import matrix from impyute.ops import wrapper # pylint: disable=invalid-name, too-many-arguments, too-many-locals, too-many-branches, broad-except, len-as-condition @wrapper.wrappers @wrapper.checks def moving_window(data, nindex=None, wsize=5, errors="coerce", func=np.mean, ...
2ca3948ba9af8efa85fb7d6edc9b1792730a3d5677ae54bb7de15bec0b5764a2
Python
4,991
149
''' GeH4OH ''' import numpy as np import sys def intro(): print(""" SHORT List of potential energy surfaces for GeH4OH: 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...
c8d8c4b15b2c6cda1fefd5de390a40495adb69b5349b6184801e9cb312ab40a8
Python
4,993
162
import os import numpy as np from tqdm import tqdm from glob import glob from scipy.stats import mode from fiberpipeline.utils import get_basename from nicety.conf import get_conf from tqdm import tqdm from joblib import Parallel, delayed from sklearn.decomposition import PCA from collections import defaultdict de...
e5866d379bad9d16b2e302d732c3eec4197c9acc201306f67ef74c58e983e124
Python
4,993
147
#!/usr/bin/env python import warnings warnings.filterwarnings("ignore", message="numpy.dtype size changed") warnings.filterwarnings("ignore", message="numpy.ufunc size changed") import pandas as pd import numpy as np from sklearn.externals import joblib from PAINTeR import global_vars import PAINTeR.connectivity as con...
aca8aab6a99873010cdf02b8e8c57336694999f41df72d5f9e15b8fdde5b0ded
Python
4,994
141
import json import os import os.path as osp from itertools import product from typing import Callable, List, Optional import numpy as np import torch from torch_geometric.data import ( Data, InMemoryDataset, download_url, extract_zip, ) from torch_geometric.utils import remove_self_loops class PPI(I...
0be8e1850456ac164043923e569c5470a06bf293bc06b12ff446c3a511e09c0b
Python
4,995
157
# vessap open graph benchmark dataset import os import os.path as osp import sys import sys sys.path.insert(0, '../') sys.path.insert(0, '../../') sys.path.insert(0, '../../ogb') import torch import numpy as np import pandas as pd import scipy import argparse import networkx as nx import torch_geometric.transforms as...
8afbd1c02abd2bf334bc9d0984f96da92c5892e2a02c4a03f106cc68f15daca1
Python
4,995
139
# -*- coding: utf-8 -*- """ Created on Wed Feb 2 08:16:52 2022 @author: Avlant-MIT """ import numpy import torch ######## MML activation def MMLactivation(x, leak=0.01): #x[x<0] = leak*x[x<0] #x[x>=0.5] = 0.5 * (1 + (1./(0.5/(x[x>=0.5]-0.5) + 1))) x = numpy.where(x < 0, x * leak, x) x = numpy.where(x...
e3d6440c49db2bde8b0dca63baf155b063db9f4433efbaa1ec0bd39803d87bab
Python
4,995
150
# This file is part of Zennit # Copyright (C) 2019-2021 Christopher J. Anders # # zennit/types.py # # Zennit is free software: you can redistribute it and/or modify it under # the terms of the GNU Lesser General Public License as published by the Free # Software Foundation; either version 3 of the License, or (at your ...
ddd4e12ebae0200d9d62b094d5ed1587682c5b3ca7fb4fa47763bcc996091ee1
Python
4,996
136
import argschema as ags import numpy as np import pandas as pd from skeleton_keys.io import ( load_default_layer_template, write_dataframe_to_csv, read_csv, read_json_file, ) from skeleton_keys import cloudfields class ProfilesFromAlignedCoordsParameters(ags.ArgSchema): coordinate_file = cloudfiel...
e604cfe7211589db99c3e6a17dc2b64a5581ec92ce0db825bb51ed0e618632de
Python
4,996
112
# flake8: noqa """run_youtube_vis.py Run example: run_youtube_vis.py --USE_PARALLEL False --METRICS HOTA --TRACKERS_TO_EVAL STEm_Seg Command Line Arguments: Defaults, # Comments Eval arguments: 'USE_PARALLEL': False, 'NUM_PARALLEL_CORES': 8, 'BREAK_ON_ERROR': True, # Raises exc...
d21621eac0fcbf19dc263d9793550da672425ef68b56ad58577570d724078c02
Python
4,998
161
""" A DeepReg Demo for classical affine iterative pairwise registration algorithms """ import argparse import os import shutil import h5py import tensorflow as tf import deepreg.model.layer_util as layer_util import deepreg.util as util from deepreg.dataset.preprocess import gen_rand_affine_transform from deepreg.reg...
24a1a4a5e985eb0418a432c8be94572016a35ce62270050dabb287c081aa39cf
Python
4,999
151
from typing import Tuple, Type from dipy.utils.optpkg import optional_package from scilpy.ml.utils import IMPORT_ERROR_MSG torch, have_torch, _ = optional_package('torch', trip_msg=IMPORT_ERROR_MSG) """ The classes in this file are from the SAM-Med3D repository: https://github.com/uni-medical/SAM-Med3D """ cl...
34dd41919cd3a79942a27df5837ef7ac8a08392abe8a3076c822ffe93de8109b
Python
4,999
136
# Copyright (C) 2019-2022 Intel Corporation # Copyright (C) CVAT.ai Corporation # # SPDX-License-Identifier: MIT import shutil from datumaro.components.annotation import AnnotationType from datumaro.components.dataset import Dataset from datumaro.components.transformer import ItemTransform from cvat.apps.dataset_man...
997a193bfa845aac160a3c5b870bbc71d5ba5f14641ba140df4d9e386c487eed
Python
5,000
154
from __future__ import absolute_import from collections import defaultdict import math import numpy as np import copy import random import torch from torch.utils.data.sampler import ( Sampler, SequentialSampler, RandomSampler, SubsetRandomSampler, WeightedRandomSampler) def No_index(a, b): assert isinsta...
bb770f0b7e87805e2499496653e97252e1a7702d385a91a165cfb4df4adba68c
Python
5,001
187
# -*- coding: utf-8 -*- """ Convolve volumetric data with a 3d kernel, optimized for memory / float32 use Based on `scipy.signal <http://docs.scipy.org/doc/scipy/reference/signal.html>`_ routines. Author """""" Original code from `scipy.signal <http://docs.scipy.org/doc/scipy/reference/signal.html>`_. Modifi...
3debf29bb0ac35869af56ea43d11a430dc9e90b2260acb70a32a7cb50481e819
Python
5,002
134
import datajoint as dj from staticnet_analyses import base from staticnet_experiments import models as static_models, configs as static_configs, utils from neuro_data.static_images.configs import DataConfig from neuro_data.static_images import stats import numpy as np from itertools import count schema = dj.schema('zh...
68bf502a5ca7d1c8fc469076684723a27e4336c979552723139b3f20ef8b94f0
Python
5,002
136
import torch from torch import Tensor from bism.utils.morphology import binary_erosion from yacs.config import CfgNode import numpy as np def _make_neighborhood(radius: int = 1, device='cpu'): """ Creates a matrix of pixel connected components. :param radius: distance of connected components :param d...
9b53b9b23c4a0957b1931241934c13e75ce503906d164b8fda2f6e2cb063956e
Python
5,002
119
""" file: Graph_Analysis_Demo.py author: Tiago Ferreira, Cameron Arshadi version: 20190402 info: Demonstrates how to handle neurons as graph structures[1] (graph theory) in which nodes connected by edges define the morphology of the neuron. SNT represents neurons as directed g...
a343ac633d2bc6d3bae0c6b2e9bf74f09cc41701bae437a1c88d2988a328dae4
Python
5,002
96
import os from nipype.interfaces.base import ( CommandLine, CommandLineInputSpec, TraitedSpec, File, traits, isdefined, ) class PlotTckOnSliceCmdInputSpec(CommandLineInputSpec): # Must appear immediately after "python" in the command script_path = File(exists=True, mandatory=True, arg...
ba2acc17123916ddd51487259c792ac1d7ab409cb8f6b30564f3171342a09452
Python
5,004
145
import argparse import glob import os import random import shutil import sys import numpy as np import pytorch_lightning as L import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.data as data import torchvision as tv from lightning.pytorch import loggers as pl_loggers from pytorch_ligh...
c0ea9b0d9bc4fd8c5e4eed2e8bd13a609862c4e669d9ab41cd348c0a704c4e32
Python
5,004
161
from typing import Optional from pathlib import Path import typer from typing_extensions import Annotated from importlib.metadata import version from brainles_preprocessing.modality import Modality, CenterModality from brainles_preprocessing.normalization.percentile_normalizer import ( PercentileNormalizer, ) fro...
ea3eed1312eedd6c32ac63f6753389f05359bdab373219dbb1e11204287f4aa8
Python
5,004
123
#!/usr/bin/env python """ HAL module for Coherent laser control. Hazen 04/17 """ import storm_control.hal4000.halLib.halMessage as halMessage import storm_control.sc_hardware.baseClasses.amplitudeModule as amplitudeModule import storm_control.sc_hardware.baseClasses.hardwareModule as hardwareModule class CoherentL...
166c04c29b2138cdd2da5b151b6e90c6d42b21ac5db61d706a2ac807246021c4
Python
5,005
131
############################################################################# # Copyright (C) 2020-2026 MEmilio # # Authors: Henrik Zunker # # 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 Lice...
e67a227e016254b5415eb7c444d7ef9b887c6603a51424860615e7d8d6a59a0b
Python
5,005
131
# Copyright 2024 Google LLC # # 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, ...
29cd4a567ee8e826d1e1315e8679108f44605c9861537955dcfa31e8a3542eea
Python
5,008
161
""" Loss Functions for AVPENet. Implements the composite loss function from Section "Loss Function Design", Equations 24–27: L_total = α · L_MSE + β · L_ordinal + γ · L_smooth where: L_MSE = mean squared error (primary metric) L_ordinal = ordinal consistency loss (encourages rank ordering) L_smoo...
3878ca3aa35b95e628f10bfca8895ba5826e99005a998b5cc839293d2f054147
Python
5,008
121
import skimage.io as skio import numpy as np from natsort import natsorted from skimage.morphology import label from napari_simpleitk_image_processing import label_statistics import time from tqdm import tqdm import os import glob import parameter_search.helper as helper import pandas as pd # Setting up the parameters...
560910a96f5505ab71de071a28a9726232bbe45e14137e18a840f1a89c094ef7
Python
5,008
130
import warnings from typing import Optional, Union import torch from torch import Tensor import torch_geometric.typing from torch_geometric.nn.conv import MessagePassing from torch_geometric.nn.dense.linear import Linear from torch_geometric.typing import OptPairTensor # noqa from torch_geometric.typing import OptTe...
f4f63b81a39e15d991421e23bcf87ca093063ff533f5e7623c4d20225712baac
Python
5,009
148
import argparse import os import os.path as osp import time import numpy as np import torch import torch.nn.functional as F from sklearn.metrics import f1_score import pandas import json import torch_geometric.transforms as T from tqdm import tqdm import spacy import re from vaderSentiment.vaderSentiment import Sentime...
1e511cc06cd94b7751e08f6cb91580d78d4a330ad535b83223cec04a4282aea0
Python
5,010
174
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Common io helper functions """ import os import argparse import pickle def str2bool(arg_in): """ Convert a string argument to a boolean. Parameters: ----------- arg_in : str or bool Input argument to be converted. Returns: ...
b61a31405305fe28a490f5a49cd1efb53eb0b1d5e19d6e237bc45dbbe8a24dbd
Python
5,010
149
import argparse import os import os.path as osp import time import numpy as np import torch import torch.nn.functional as F from sklearn.metrics import f1_score import pandas import json import torch_geometric.transforms as T from tqdm import tqdm import spacy import re from vaderSentiment.vaderSentiment import Sentime...
cbe9b2fb4d6242ffff627fa791ae1334cfd60a22b4d07b1790343ad07b529532
Python
5,010
149
import argparse import os import os.path as osp import time import numpy as np import torch import torch.nn.functional as F from sklearn.metrics import f1_score import pandas import json import torch_geometric.transforms as T from tqdm import tqdm import spacy import re from vaderSentiment.vaderSentiment import Sentime...
41834af965b6af07965c2303c625e0ab7a09c59a95a090eb048d58e707dd75d5
Python
5,011
115
import os import numpy as np import skimage.io as skio import dask_image.imread COORDS = { 'LADAF-2020-27':{ '2.58um_to_12.1um':{ "x_range": (765, 1049), # last already + 1 "y_range": (819, 1103), # last already + 1 "z_range": (123, 1281), # last already + 1 ...
4b369adf102102091589c92fdae075ac456dbf15d91cbc60d424664bc33d9ba5
Python
5,011
140
# Copyright 2024 DeepMind Technologies Limited # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agree...
38e44b2368c9a7d8020e33032a6ef5e9e168eacf61a698c1b1378ffc365cbc81
Python
5,013
131
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Evaluate graph theory measures from functional connectivity matrices. The functional connectivity matrix is assumed to come from fMRI bold correlations (-1 to 1 values). Hence, the matrix is first made strictly positive (absolute value) and thresholded above a certain ...
e94e332502ed82c6d302d877f366d06202d024e7006f3d7543cb0229f29d3205
Python
5,013
157
from collections import OrderedDict from collections.abc import Sequence from dataclasses import dataclass from typing import TYPE_CHECKING, Literal import torch from torch import nn from eir.models.layers.mlp_layers import MLPResidualBlock, ResidualMLPConfig from eir.models.models_utils import ( calculate_module...
216fabfd49f3f8c19debf40cbc657fcdb98d04e6635820965e6847cd77d88134
Python
5,014
171
""" Task manager for organizing parallel processing results. Handles task submission, completion tracking, and result organization. """ import threading import time from dataclasses import dataclass, field from typing import Optional, Dict, Any, List from enum import Enum class TaskStatus(Enum): """Status of a p...
29651cc70dba2ed7149a8868a48453657a2fc8ad252af038af13b55cb88c2386
Python
5,014
92
import os def setup_environment(system_mode="local-H-Drive"): if system_mode == "local-H-Drive": # Example structure for local path management regarding this project os.environ['DATA_PATH'] = r"H:\Users\Username\Data" os.environ['COMPLETE_TRIPLE_PATH'] = r"H:\Users\Username\Data\filenames_csv" ...
a94ef23fa9a1af017cba712cf9d5244477189f00edb55762e8ae0484c1713165
Python
5,014
135
""" Concatenates and normalizes EEG data Saves a .mat file with task- and period-specific EEG for all participants. Also optionally saves a .mat file with the nonnormalized, task and period specific EEG concatenated for all participants """ import mne import os import glob import numpy as np import pandas as pd from ...
3ab38b1915444983bb5e0d0d11eda49a4bf6cbbfaf49f2916f527b2342534786
Python
5,016
133
# Kai Sandbrink # 2023-02-01 # This script computes the learning curves for specified test models # %% LIBRARY IMPORTS import torch import pandas as pd import numpy as np from utils import Config, get_timestamp, flatten from utils_project import load_config_files from test_case import test import os, copy, pickle imp...
6c6274fd59639b4f6968f027a50061b7a75b0f5aeef159d2cba99c959ea97b35
Python
5,016
145
import sys import yaml import os import numpy as np import h5py import matplotlib as mpl import matplotlib.pyplot as plt pathpath,myrun,ncluststr,cmethod = sys.argv[1:] ''' pathpath = 'PATHS/filepaths_carlen.yml' myrun = 'runC00dMP3_brain' ncluststr = '8' cmethod = 'ward' ''' ncl = int(ncluststr) with open(pathpa...
956529675b59c31575c3204fcf3338e07343b0775fb78bbea939bcb7153bb23b
Python
5,016
138
""" This module contains functions for calculating selectivity and related metrics. """ import numpy as np from sklearn.metrics import roc_auc_score def bootstrap_rate_diff(condition1, condition2, n_reps=1000): """ This function performs a bootstrap test to assess the significance of the difference in fi...
f00044ee2ffcea9ba29f9f723c3bb5a43bc00bef100934703044b2db7a442433
Python
5,017
114
# flake8: noqa """run_youtube_vis.py Run example: run_youtube_vis.py --USE_PARALLEL False --METRICS HOTA --TRACKERS_TO_EVAL STEm_Seg Command Line Arguments: Defaults, # Comments Eval arguments: 'USE_PARALLEL': False, 'NUM_PARALLEL_CORES': 8, 'BREAK_ON_ERROR': True, # Raises exc...
eba817296c79fb07ea6e3bbe9e26b4e52ea9813b96754a9dd619cda7334aa8b5
Python
5,019
151
""" Audio Encoder for AVPENet. Modified ResNet-34 architecture adapted for mel-spectrogram processing. Input: (B, 1, 128, 300) — mel-spectrogram Output: (B, 512) — audio embedding Reference: Section "Audio Encoder Architecture" of the paper. """ import torch import torch.nn as nn import torch.nn.function...
27dc4df11464f18a981a00096d8f914137b35a5acb0dd543116940c509b9afb9
Python
5,021
135
from typing import Any, Callable, Dict, List, Tuple, TypeVar, Iterable, Iterator import re import torch import numpy JsonDict = Dict[str, Any] # If you want to have start and/or end symbols for any reason in your code, we recommend you use # these, to have a common place to import from. Also, it's important for some e...
4c5aa8e356401ed30c56619587946f2c8f0dc676dea3c8bb8d64b432542fc747
Python
5,021
152
import tkinter as tk from tkinter import messagebox, simpledialog, filedialog from impedancefitter import Fitter, available_file_format directory = None def browse_button(): global directory directory = filedialog.askdirectory() class MainWindow(tk.Frame): def __init__(self, master=None): tk.F...
53606f1cb2f35aa4e3be4d7579e4c419b022d1263960e621d3993edb6f26a8d6
Python
5,023
138
# Copyright (C) CVAT.ai Corporation # # SPDX-License-Identifier: MIT from collections.abc import Iterator from datetime import datetime from pathlib import Path from typing import Any, ClassVar from attrs import field, frozen, validators from django.apps import AppConfig, apps from django.utils import timezone from r...
1a741f3a85b41abc423cc2e85cb16ab4a76166a47537dfd67b6a16b1fd0ebd37
Python
5,024
116
import numpy as np from scipy import stats from utils import Recorder_select, Q_nak from mitochondria import Mito import matplotlib.pyplot as plt from figure_properties import * from default_ca_conc import ca_freq_concs dt = 0.1 seed = 11 np.random.seed(seed) def generate_spiketrain(rate, duration): # duration giv...
af2a6da4cc6d5a412789ded4eb1732414bfb6db85379c2f0fb614a18980943d6
Python
5,026
141
## ------------------------------------------------------------ ## IMPORTS ## ------------------------------------------------------------ import torch import torch.nn as nn from LSTMConvCell import * ## ------------------------------------------------------------ ## Explain the block ## -----------------------------...
9d79b25ee03fdc85c5d5efef00460c390153f6da6c7804c4bdfd8697bc90688b
Python
5,027
115
# Copyright 2024 Google LLC # # 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, ...
ff349f4719fc95f6bd77b38251440cdc9426d09bc6164c436e289b679682b0b4
Python
5,027
160
#%% imports from convenience import get_collection from construct import reconstruct_from_folder from sys import platform import pandas as pd import yaml from pathlib import Path collection = 'mito_ideas_models' if platform == "linux" or platform == "linux2": main_folder = Path("/mnt/LEB/Scientific_projects/deep_...
82a35c49f76904620d4b0b0d4b93cf25ac604379c8b8bffde58599a874d29201
Python
5,028
128
#! /usr/bin/env python3 # -*- coding: utf-8 -*- """ Detect sign flips and/or axes swaps in the gradients table from a fiber coherence index [1]. The script takes as input the principal direction(s) at each voxel, the b-vectors and the fractional anisotropy map and outputs a corrected b-vectors file. A typical pipeline...
afdd488e3eb080d42785d1a5c449b0f9ff01b1cc03d8151a573195bda7159a56
Python
5,028
119
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved # 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 warnings import torch import torch.nn as nn import torch.nn.functional as F from torchvision.t...
87317ccf030deb907b52deea1118d73e57507bfc5571c35b7c37fe2213ea66fa
Python
5,033
120
""" Run decoding analyses by eccentricity. """ from utils.prepare_data import PrepareData from utils.foveal_decoding import FovealDecoding import matplotlib.pyplot as plt import pandas as pd accuracies_exp_all = pd.DataFrame() accuracies_control_all = pd.DataFrame() accuracies_cross_all = pd.DataFrame() se_exp_all = ...
08b450e09fb4046506a6599be6f4e7958103ec648aaaa0b196823b5a31d99ff7
Python
5,035
129
# Copyright (C) CVAT.ai Corporation # # SPDX-License-Identifier: MIT """Attach an S3-compatible bucket to CVAT as a cloud storage, then list, retrieve, and update it. Any S3-compatible service works (AWS S3, minio, ...) via the AWS_S3_BUCKET provider and a custom endpoint URL. There is no high-level proxy for cloud s...