sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
2f128dab87a2822f154a58200d937955444fe39c80ba18dfdab43f14540f016a
Python
5,365
133
import jax import jax.numpy as jnp import matplotlib.pyplot as plt import os import plot_utils import json jax.config.update("jax_default_matmul_precision", "high") plt.rcParams["font.sans-serif"] = ["DejaVu Sans"] plt.rcParams["font.family"] = "sans-serif" plt.rcParams.update({ "font.size": 10, "axes.t...
eb1af6363b08bc6ffb6dc277782a3506df8cb36ea06d69a9d2e23026745ae571
Python
5,366
126
import pandas as pd import numpy as np import os import glob root = '{0}Users{0}mococomac{0}Documents{0}data_backups{0}Bouba{0}original_format{0}bouba_scans{0}preproc2{0}'.format( os.sep) global_dict = {'round': 1, 'mixed_round': 2, 'mixed_spiky': 3, 'spiky': 4} subs_list = [os.path.basename(x) for x in glob.glo...
5d588141fb616bde5f82efe38d7e158a226fdd122466b77c6b367ca2ed2fe830
Python
5,367
142
from brainscore_vision.model_helpers.check_submission import check_models import functools from transformers import AutoFeatureExtractor, CvtForImageClassification from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper from PIL import Image import numpy as np import torch """ Template module fo...
6486707009cf2c8ce6fb462d81f6c4ff2c96bb2c185cfbb43671640ebd2d732b
Python
5,367
142
from brainscore_vision.model_helpers.check_submission import check_models import functools from transformers import AutoFeatureExtractor, CvtForImageClassification from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper from PIL import Image import numpy as np import torch """ Template module fo...
951fd2687dac67ea9c8fa4ac606e22060936208170fa76eca45cc518edc3543d
Python
5,367
145
import numpy as np import pandas as pd from sklearn.ensemble import RandomForestClassifier from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score, matthews_corrcoef, auc, roc_curve, \ roc_auc_score from sklearn.metrics import classification_report from sklearn.metrics import confusion_m...
35775932e97aa9527dea735aaec6c25bd2e452dc210d06c9a9ec3f58ebe459a0
Python
5,368
137
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Split a tractogram into multiple files, 2 options available : Split into X files, or split into files of Y streamlines. By default, streamlines to add to each chunk will be chosen randomly. Optionally, you can split streamlines... - sequentially (the first n/nb_ch...
7d9d9866fdc0ed2fa082d62c81cf64b554949a278cc7502575bbddeee661f070
Python
5,368
99
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'destination.ui' # # Created by: PyQt5 UI code generator 5.7 # # WARNING! All changes made in this file will be lost! from PyQt5 import QtCore, QtGui, QtWidgets class Ui_Dialog(object): def setupUi(self, Dialog): Dialog.setObjec...
cdcf87f87b9c5bd568ba9fd2b7554db56571e596586ea66edeaf0f413d9c3816
Python
5,368
142
import math import torch import numpy as np import random def gaussian_kernel( sigma: float, k: float=1, size:float=15, norm:bool=False ) -> torch.tensor: """Returns a 2D Gaussian kernel. :param sigma (float): standard deviation of the Gaussian :param k (float, optional): height of the Gaussian ...
e80e72e1a6c69c99557425c0b61a2ac03da792668cad7a058abccc9072a843a4
Python
5,368
179
import numpy as np def threshold_classifier(dtheta_seqs, left_threshold, right_threshold): """Classify re-orientation angles into 3 states based on 2 thresholds. Re-orientation angle δθ are classifed as followed : - δθ < :left_threshold: → 1 - δθ > :right_threshold: → 2 - :left_thres...
f0680767724649de5658c1c20ff401e44e32769bff1211459022878d2450995b
Python
5,368
134
# wfield - tools to analyse widefield data - plotting the results / summary plots # Copyright (C) 2020 Joao Couto - jpcouto@gmail.com # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either ...
017cf144a4cfc5c8331c04c894cc365cb7cd1a346d5a2df9f5f5828ebb61813b
Python
5,369
133
import matplotlib.pyplot as plt import numpy as np import figure_properties as fp from utils import Q_nak, Recorder from mitochondria import Mito dt = 0.01 def single_spike(spike_at=150, q=1, t_start=150, t_run=5000, t_ca1=7000, t_ca2=20000): tt = np.arange(0, t_run, 0.01) spike_costs = np.zeros_like(tt) ...
7da2938a57bb290166bcf7e1cbbbd7ca19ec80347cdd4416c181ccd8c388fe5d
Python
5,369
165
#!/usr/bin/env python3 # inference.py """ 推理脚本 —— 加载分类与回归模型,生成手术指征与剂量预测 流程: 1. 读取输入特征(6 维),并使用训练时保存的 StandardScaler 做同样的预处理。 2. 对预处理后特征,使用所有折的分类模型做前向,平均概率,阈值化生成初步二值 mask。 3. 对每个样本的冲突预测(同一眼内直肌“缩短”与“后徙”同时为 1),只保留概率更高的一项。 4. 使用所有折的回归模型在 mask 掩码下做前向,平均预测剂量。 5. 将最终的手术指征(0/1)与手术剂量(mm)组合输出。 使用: $ python inference.py --input...
f91b8513c7d11425e902a67911a432637a4e3f8530c2ad0bf8041b2a818ce43e
Python
5,370
118
# Copyright (C) CVAT.ai Corporation # # SPDX-License-Identifier: MIT import unittest from contextlib import ExitStack, nullcontext from types import SimpleNamespace from unittest import mock from cvat.apps.quality_control import quality_calculators from cvat.apps.quality_control.data_providers import JobDataProvider ...
a0d6da5aeb6ae214b67d910368723f39a69c9471c3feddc36dcc0582c84bf2d8
Python
5,372
174
#!/usr/bin/env python3 # This script is included in documentation. Adapt line numbers if touched. import arbor as A from arbor import units as U import pandas as pd import seaborn as sns import sys from pathlib import Path # (1) Read the morphology from an SWC file. if len(sys.argv) == 1: print("No SWC file passe...
14911df9670f6b56ce7199016f1c5d8c2198009fcbcf1c80de87c26d959e6e52
Python
5,373
176
# -*- 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 ------------------------------------------------------------...
2dc8d3e3913faee52b77fb27f70de0a4380440f56cc815b4652da29d2f9f0bf9
Python
5,373
183
from __future__ import annotations import sys import pytest from PySide6 import QtGui from pytestqt.qtbot import QtBot from labelme._automation import AiOutputFormat from labelme._widgets._ai_assisted_annotation_widget import AiAssistedAnnotationWidget @pytest.fixture def models() -> list[str]: return [] @py...
59ea889e1e7d62ce22dcb9d339c9439926a03b05f167b2ecc5d750d5c5c68e6d
Python
5,373
128
"""Density samples outside the tomogram must be NaN, not extrapolated. `interpn(..., fill_value=None)` extrapolates linearly from the edge, which is unbounded: a linescan leaving the volume produced invented values that the thickness fitter could not distinguish from real data. These pin the honest behavior and the do...
861e475f2129bac6c72c2ef00fe19d015fa333bf0079edd848716bea0c23531e
Python
5,373
123
"""Console progress for the scaling example, including executor subgraphs.""" from datetime import datetime, timezone from itertools import islice import json from threading import RLock import time from langchain_core.callbacks import BaseCallbackHandler def summarize(value, depth=0): """Bound tool payloads wh...
89359105ad3c829c9dba3ac2d55843df1a4f4e3f6b70422e931a9fa513681362
Python
5,373
100
#!/usr/local/bin/python3 from pipeline import experiment, reso, meso, fuse, stack, pupil, treadmill, posture from stimulus import stimulus from stimline import tune import time import logging import datajoint as dj ## database logging code logging.basicConfig(level=logging.ERROR) logging.getLogger('datajoint.connect...
beb676b4f560660b72948e2741bdeb9c00b41f677dd6a91f2084a974eb2c21e8
Python
5,373
82
#!/usr/bin/python import os def create_key(template, outtype=('nii.gz',), annotation_classes=None): if template is None or not template: raise ValueError('Template must be a valid format string') return template, outtype, annotation_classes def infotodict(seqinfo): """Heuristic evaluator for ...
ddd1ee1a13c877fdcb01d38516707bcd6ab6a8084264b0734ecb5a2a1309335b
Python
5,373
176
# -*- 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 ------------------------------------------------------------...
e9ac4caeb38d508872c7dc9fa95de743cff683f60fca41fad2d266bb8ea21767
Python
5,374
137
""" Various useful function related to IVIM scanning on Philips MRI systems. """ import os import numpy as np import numpy.typing as npt from ivim.io.base import read_bval, write_cval from ivim.seq.fwf import c_from_b def generate_dti_vectors_input(b: npt.NDArray[np.float64], filename: str, dualpol: bool = False, hea...
20b14e949780ad6cfb2dbc020662be86238547466ddd66ea3ec7aa0003cf9421
Python
5,375
181
from collections.abc import Callable, Sequence from typing import ( TYPE_CHECKING, Any, Optional, Protocol, Union, ) from eir.experiment_io.io_utils import get_run_folder_from_model_path from eir.predict_modules.predict_tabular_input_setup import ( ComputedPredictTabularInputInfo, ) from eir.se...
43bc0df983d6eba204a6dfe38442e5733882ed473fb3471ef4311f5e24faec09
Python
5,375
151
"""Script to extract laminar resting state activity from digit ROIs""" import nibabel as nb import numpy as np import glob import os ROOT = '/Users/sebastiandresbach/data/s1Anfunco/Nifti' # Set subjects to work on # subs = ['sub-15', 'sub-16', 'sub-17', 'sub-18'] # subs = ['sub-06', 'sub-09', 'sub-10', 'sub-12', 'su...
2df33dbb0d5449678f516686cc7894999b3b565b8212f9f09feff319f0eb1e28
Python
5,376
172
import contextlib import json import os import re from pathlib import Path from typing import Optional import click import matplotlib as mpl import matplotlib.colors as mcolors import numpy as np import pandas as pd from simple_mri import SimpleMRI, load_mri, save_mri def inverse_dict(index): inverse = {} fo...
1a354a32f12ad64dac795b22a1483d70e2136d410edd8c92dcd396ca54f2bd85
Python
5,377
140
import matplotlib.pyplot as plt import numpy as np import nems from nems import Model from nems.layers import WeightChannels, FiniteImpulseResponse, RectifiedLinear, STRF from nems import visualization from nems.metrics import correlation from nems.models.LN import LN_plot_strf import tensorflow as tf # Check if eage...
47e77b22e7fe45b8ab0ffe6b9e52e801eecd27c83b525e2eabdd453f025e6b7c
Python
5,378
118
import os import pandas as pd import numpy as np import argparse def perturb_graph(data_path, graph, perturbation_mode, k=0, seed=123): np.random.seed(seed) if graph == 'train1': df = pd.read_csv(os.path.join(data_path, 'train1.txt'), sep='\t', header=None) elif graph == 'train2': df = pd....
6974add46d50fbcb6569daf2080591384f08dac2a4f56b1bae5c011ec30f6be6
Python
5,378
238
# Copyright (C) CVAT.ai Corporation # # SPDX-License-Identifier: MIT """Read-only annotation model independent of storage and conversion libraries. Labels refer to positions in the accompanying catalog, not database label IDs. Adapters retain source references separately from representation-specific IDs. """ from ab...
ce2bc9f13aa421f6fe67eb0e2a0c91b59bc9c50f1b759265e0082c5963b1f3a1
Python
5,380
129
alg_name = 'node2vec' import os os.environ["OMP_NUM_THREADS"] = "2" # export OMP_NUM_THREADS=1 os.environ["OPENBLAS_NUM_THREADS"] = "2" # export OPENBLAS_NUM_THREADS=1 os.environ["MKL_NUM_THREADS"] = "2" # export MKL_NUM_THREADS=1 os.environ["VECLIB_MAXIMUM_THREADS"] = "2" # export VECLIB_MAXIMUM_THREADS=1 os.env...
36c7991e585a1727fc61a6b9d321cb271fb899ba54d3d2ffae8573f6d5bda962
Python
5,381
141
# -*- coding: utf-8 -*- # @Author : LG import functools from PyQt5 import QtCore, QtGui, QtWidgets from ISAT.ui.shortcut_dialog import Ui_Dialog class ShortcutDialog(QtWidgets.QDialog, Ui_Dialog): def __init__(self, parent, mainwindow): super(ShortcutDialog, self).__init__(parent) self.mainwin...
6bc5a777dc08e37e42de08ef793e49afe9fd5b27b94f617f69e6d7a66a1f1649
Python
5,381
152
# Source: https://github.com/neuraloperator/neuraloperator/blob/main/neuralop/training/training_state.py """ Snippet to load all artifacts of training state as Modules without constraining to use inside a default Trainer """ from typing import Union from pathlib import Path import torch from torch import nn import to...
cf7d9d7687e58019f972d055ecd48dd0b0a3e26f69235a09eca79d429b85c4d5
Python
5,381
133
# Mixed precision from tensorflow.keras import mixed_precision mixed_precision.set_global_policy("mixed_float16") import numpy as np from tensorflow.keras.optimizers import Adam from tensorflow.keras.optimizers.schedules import PolynomialDecay from tensorflow import concat as tf_concat from json import dump as json_du...
9fc884c6ea42ab29bbca51f2a103b59383c6ed13fe5848c672a9dff73bd6ea47
Python
5,382
150
# -*- coding: utf-8 -*- # @Author : LG import os from PyQt5 import QtCore, QtGui, QtWidgets from ISAT.ui.file_dock import Ui_Form class FilesDockWidget(QtWidgets.QWidget, Ui_Form): def __init__(self, mainwindow): super(FilesDockWidget, self).__init__() self.setupUi(self) self.mainwindo...
c60a6d2fb67bdee7a9d3262235e4a692de6ded6b7bc814f9a12a91a5201f85f1
Python
5,382
135
from zigzag.classes.io.onnx.parser import Parser from zigzag.classes.io.onnx.utils import ( get_node_input_output_dimension_shapes, get_attribute_ints_with_name, ) from zigzag.classes.workload.layer_node import LayerNode import logging logger = logging.getLogger(__name__) class GemmParser(Parser): """Pa...
a0bb1baa1dc76158e0f255b801b290a655b493ec4795b2253a000c17aaf86eb4
Python
5,383
119
""" Selective Kernel Convolution/Attention Paper: Selective Kernel Networks (https://arxiv.org/abs/1903.06586) Hacked together by / Copyright 2020 Ross Wightman """ import torch from torch import nn as nn from .conv_bn_act import ConvNormAct from .helpers import make_divisible from .trace_utils import _assert def ...
68445885ed396ae71b1fdc6554b7f7231bb2dff799b2c74f4cd62bfec55e3f3a
Python
5,385
132
import numpy as np import matplotlib.pyplot as plt import matplotlib import scipy.signal from matplotlib import gridspec from numpy import loadtxt import module_utility import scipy import random # angle_colume = 14 # access angles from this colume num_samples = 36 # number of samples output_table = np.zeros((20, num...
929ac630f160bb19017563f88658f460a0af590fe5eb0bb4242da17ed96a3fd7
Python
5,387
151
"""Minimal EDF / EDF+ reader. Written rather than taking an MNE dependency: the pipeline needs only headers, signals and EDF+ annotations, MNE does not support this project's Python 3.9 floor cleanly, and a 120-line reader is easier to audit than a large dependency when the question being asked is "what is actually in...
1def962d33775b84b2fae9a4c6b936809200327b7ec0821fd2fcfa3270867175
Python
5,388
117
# ============================================================================== # Binaries and/or source for the following packages or projects are presented under one or more of the following open # source licenses: # mask.py The OpenLane Dataset Authors Apache License, Version 2.0 # # See: # https://g...
524ac09f3e284486def94f9ebaf916996fc5e9a6b6db8a029d08475af4c727f5
Python
5,389
145
"""Offline contribution checks; runtime loading remains deliberately permissive.""" from dataclasses import asdict, dataclass from pathlib import Path import re from urllib.parse import unquote, urlsplit from deepagents.middleware.skills import ( MAX_SKILL_COMPATIBILITY_LENGTH, MAX_SKILL_DESCRIPTION_LENGTH, ...
634812541651df8dfedfff5c3ca8af5c7eb9dab14c713d78f1334b03f1a35022
Python
5,389
176
# -*- 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 ------------------------------------------------------------...
6652289f1a3d1d202b66b0ceaa50984c236c14ca3469dcbc7c5b55e58000f702
Python
5,389
111
import os from unittest import mock, TestCase import kb_python.config as config class TestConfig(TestCase): def test_get_provided_kallisto_path(self): with mock.patch('kb_python.config.PLATFORM', 'linux'),\ mock.patch('kb_python.config.os.path.isfile', return_value=True): self.as...
9296cfa5ec4de7b7a14f8a75ac2b91a59c26f7cf6d6eceee920a405a3e093d4d
Python
5,390
124
from nipype import Node, Workflow from nipype.interfaces.base import BaseInterface, BaseInterfaceInputSpec, TraitedSpec, File, Directory, traits from traits.api import Bool, Str import os, sys import numpy as np import nibabel as nib from dipy.io import read_bvals_bvecs from dipy.core.gradients import gradient_table fr...
7b8c41a557a97ec6fc07c7a029994399743920db04d2bfa125b1f43763ba4e90
Python
5,391
155
from collections import namedtuple import os import math import random from tkinter import W import pandas as pd import numpy as np from tqdm import tqdm from glob import glob import torch import torchaudio from torchaudio import transforms as T from .augmentation import augment_raw_audio __all__ = ['save_image', 'g...
3e28c7b3d80f5be94bd90fbc0bb52ff6095eb4e37e870c872d4ab6540a403ef6
Python
5,392
103
from .util import Partition, weighted_jaccard_distance, describe_sol from .problem import Problem from .seeded import solve_seeded, features_and_medians from numba import njit import math import os import datetime, time import pickle import numpy as np def partition_cost(problem, partition): return problem.eval_me...
dc0f8985cfc892bc8c408eed20335cf53b7d5a9dbfbe367be40057c880c593fb
Python
5,392
173
#!/usr/bin/env python """ Basic DAQ module functionality. Hazen 04/17 """ import numpy from PyQt5 import QtCore import storm_control.hal4000.halLib.halMessage as halMessage import storm_control.sc_hardware.baseClasses.hardwareModule as hardwareModule import storm_control.sc_library.halExceptions as halExceptions ...
bdfb246957fa146502d264e28c1ccb0f1e20b805296e27c0ae1ba0e766caab60
Python
5,395
144
"""Circular-shift shuffle test for stim-response significance. Port of ``stimShuffleTest.m`` + ``computeTrialProportion.m`` / ``computeTrialProportionForEachChannel.m`` (origin/main). The per-electrode metric is the proportion of trials where the post-stim spike count exceeds the pre-stim (baseline) count. Significan...
da2ebb6b275a45fea5ea49fa167448a826f05f428c1e9cdaa19bc209b16f92cf
Python
5,396
82
#!/usr/bin/python import os def create_key(template, outtype=('nii.gz',), annotation_classes=None): if template is None or not template: raise ValueError('Template must be a valid format string') return template, outtype, annotation_classes def infotodict(seqinfo): """Heuristic evaluator for ...
25a91012bc2153d1a1b365d7938481efc7985db6556679ca08d17660df12a061
Python
5,397
134
# Importing individual benchmarks directly is discouraged. # Use `brainscore_vision.load_benchmark` instead which provides dependency support. """ A :class:`~brainscore.benchmarks.Benchmark` runs an experiment on a :class:`~brainscore.model_interface.BrainModel` and tests the resulting measurements against primate `da...
445e707618b3edb6a5088e01d73f47711f515d628ae6b3388dd647b7f22091d5
Python
5,397
148
#!/usr/bin/env python import os import storm_control.sc_library.halExceptions as halExceptions import storm_control.hal4000.testing.testActions as testActions import storm_control.hal4000.testing.testing as testing import storm_control.test as test # # Test taking a 10 frame movie, 512 x 512. # class FilmTest1(tes...
a73e252eb3e412bffbd322341dec5512146e785f14aa09b38ce6783b422eebf9
Python
5,397
124
import nighres import os import nibabel import numpy import glob import scipy.ndimage indir = '/home/pilou/Projects/Cerebellum/Cerebellar-segmentation-ABC/sereno/tissues/' outdir = '/home/pilou/Projects/Cerebellum/Cerebellar-segmentation-ABC/sereno/topology/' wmprior = indir+'serenocb20_T1_cr_def-img_n4_wmprior.nii.g...
351754c4079ae8e9e44ba970a6f8d5bc12690f3f361b3b37042edff2ceb2ab7e
Python
5,400
120
#!/usr/bin/env python # -*- coding: utf-8 -*- # *************************************************************************** # # Copyright © 2022, UChicago Argonne, LLC # # All Rights Reserved # # Softwar...
f89d8c03b9c0561b75f92d819e6629d899a67819a0fc5b8b6205871d1e8ebcad
Python
5,400
136
#!/usr/bin/env python """ Emulated QPD functionality Hazen 04/17 """ import math import random import time from PyQt5 import QtCore import storm_control.hal4000.halLib.halMessage as halMessage import storm_control.sc_hardware.baseClasses.hardwareModule as hardwareModule import storm_control.sc_hardware.baseClasses....
484c1f5d856b23c1cddcacb9ef4923d120f6e022c1d6c3753a8e32484bb25156
Python
5,401
137
#!/usr/bin/python3 from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np import torch from torch.utils.data import Dataset class TrainDataset(Dataset): def __init__(self, triples, nentity, nrelation, negative_sample_size, mode, count, tru...
7cd4a43182725037b892b3cbc1d347f4d2e1eefcd66db484884c7eb75672900b
Python
5,401
165
"""Tools for visualizing the inputs, outputs, and parameters of Layers.""" import numpy as np import matplotlib.pyplot as plt from matplotlib.ticker import MaxNLocator from nems.layers.stp import ShortTermPlasticity from nems.preprocessing.normalization import minmax, joint_minmax from nems.distributions import Norma...
4030295cfc95edf817b37c7d9f5cf1691e8f8e8ed7aa1008749f058c00cb5ab2
Python
5,402
132
import time import torch import torchvision import torchvision.transforms as transforms from torch.utils.data import DataLoader import os from conf import global_settings as conf_set from spikingjelly.datasets import cifar10_dvs from spikingjelly.datasets import dvs128_gesture def get_cifar100_training_dataloader(ba...
c3b9994f8250dd16aa3e9ce32d3444fe872c2296d5d838d6e571a0448e990dc6
Python
5,402
150
""" Functions for visualizing analyses """ import numpy as np import matplotlib.pyplot as plt from scipy.stats import sem from stats_utils import * """ Plots the sections in time corresponding to each playing mode: inv, shinv and norm. Each is shaded a different colour. section_list: the list of start and end times o...
595c7481ec23be86f2e3b93c7cfe7ec14c22cd495c54eb6215ba9284e35669d3
Python
5,405
178
# -*- 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/stable/config # -- Path setup ------------------------------------------------------------...
7e8f769d6ce514e0e0dc91d8601700ece1579c69e027b21a79787d84fff540c3
Python
5,407
149
import torch from torch.nn import Parameter from torch_geometric.nn.conv import MessagePassing from torch_geometric.nn.inits import reset, uniform import torch.nn.functional as F import torch.nn as nn class NNConv_old(MessagePassing): r"""The continuous kernel-based convolutional operator from the `"Neural Mes...
63041150ab1056095239c8b7648c6c3d31f4ddb468b497d6c4aa7ba44f02b562
Python
5,409
133
"""An example script, which uses memoization to store (intermediate) results.""" # pylint: disable=duplicate-code import time import typing from collections.abc import Sequence from typing import Annotated, SupportsIndex import h5py import numpy from corelay.base import Param from corelay.io.storage import HashedHD...
8a384ffd68e75add6c2e379e6afb5b25b650ca7b7e555a7bb4706c8d122e16b3
Python
5,409
146
"""Perform MDS on the trial-average fMRI responses, or on the DDN features, for the NSD-core images. Parameters ---------- subject : int Number of the used subject. data_ood_selection : str If 'fmri', perform MDS on the fMRI responses for the NSD-core images. If 'dnn', perform MDS on the DNN features for the NSD-co...
ce5b7f3f3dfcd320c07470eda963c3684028a7cddc8079e1feceabee0c47c9ce
Python
5,411
88
import numpy as np from brainscore_core import Score from brainscore_vision import load_dataset, load_metric from brainscore_vision.benchmark_helpers.screen import place_on_screen from brainscore_vision.benchmarks import BenchmarkBase, ceil_score from brainscore_vision.model_interface import BrainModel BIBTEX = """@A...
e39c860a414e1d646d19374fb0120b82a26057f6925e09444b33a79e5c46b00c
Python
5,412
151
import sys import numpy as np from matplotlib import pyplot as plt import h5py def prColor(word, color_type): ''' function to print color text in terminal input: word: word to print color_type: which color 'red', 'green', 'yellow' ...
9309ca56c26d4a4e395e595e004d027378dd63a977d85105e8d478e007afab8c
Python
5,414
137
#!/usr/bin/env python """ Long runnings tests that are run manually, not designed for CI """ import os import storm_analysis.sa_library.datareader as datareader import storm_control.sc_library.halExceptions as halExceptions import storm_control.hal4000.testing.testActions as testActions import storm_control.hal4000....
4940b95d37cdd47b55ee255f026d0103dfad41cf9c2d957a3b9766ad630816d0
Python
5,416
124
""" Compare final Dice scores for deformable registration with Adam vs Levenberg optimizers, for both Greedy and SyN methods. """ import logging import pytest from pathlib import Path from fireants.registration.greedy import GreedyRegistration from fireants.registration.syn import SyNRegistration from fireants.io.imag...
b247913baf0498a48c1d3ad1b8b0dce6d4e3a814d51d63fca18d7ae3a2647c36
Python
5,416
137
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved from collections import defaultdict import torch import torch.nn.functional as F from .masks_ops import mask_iou from scipy.optimize import linear_sum_assignment def associate_det_trk( det_masks, track_masks, iou_threshold=0.5, ...
e311641c8fbdbdd5329a8d64067ce0b62f28e8c59181b557a2f960252facdffd
Python
5,417
174
# -*- coding: utf-8 -*- __author__ = "Felix Niemöller" __email__ = "usnrb@student.kit.edu" import torch # torchaskivit.utils from . import utils def train_one_epoch(epoch, P, d, print_interval=50): len_train = d["loader_train_len"] # Initialize loss tracking running_loss = 0.0 last_l...
829b939bc371115e9559eea5cc6e484554d4d7e7fcf87fc4b150a704f1ebb03a
Python
5,418
171
#!/usr/bin/env python import argparse import sys from pathlib import Path import imgviz import numpy as np from numpy.typing import NDArray sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) import utils # noqa: E402 # examples/utils.py, vendored alongside this script def _create_output_directories...
06d03463ea00e458906b37219a71ff8132ed6067282e05bc5f4ecd7e3c2ff397
Python
5,419
123
import os import numpy as np import cv2 import argparse import onnxruntime from tqdm import tqdm parser = argparse.ArgumentParser() parser.add_argument("--model-path", type=str, default="./yolov5s6_pose_640_ti_lite_54p9_82p2.onnx") parser.add_argument("--img-path", type=str, default="./sample_ips.txt") parser.add_argu...
1bdabde7eb1bcec15e302c652b86c5d74d2bbc83e4e420d43770e2b42b6b0e61
Python
5,419
149
import torch import torch.nn as nn import torch.nn.functional as F from torch import einsum # --- 辅助模块 --- class Swish(nn.Module): def forward(self, x): return x * torch.sigmoid(x) class ConvBlock(nn.Module): """ 轻量级卷积块,用于捕捉局部特征. 使用深度可分离卷积 (Depthwise Separable Convolution) 提升效率. 结构: Point...
5590d6a3102631d9c28dc194a4fe475df7e51d1cd8dd9ede7b81035cabfe0be9
Python
5,420
93
""" If you use this code, please the SynthSR paper in: https://github.com/BBillot/SynthSR/blob/master/bibtex.bib Copyright 2020 Benjamin Billot 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:...
fb28cf5b53bcc65cab46748ab2c80cbc60718821eb902ae2ed77ca896e35c89c
Python
5,421
140
import sys, os, copy import torch from monai.config import print_config from monai.transforms import ( AddChannel, Compose, LoadImage, EnsureChannelFirst, ScaleIntensity, ToTensor, HistogramNormalize, ResizeWithPadOrCrop ) from monai.data import NibabelWriter from utils.netdef import ShuffleUNet import numpy as...
11286b296898f701d4848e58e19f4a9c02fc7de81433dbb85190fd86e2b1c48b
Python
5,422
152
"""mapsurfacetovolume """ import numpy as np from scipy import sparse from nsdcode.utils import zerodiv __all__ = ["mapsurfacetovolume"] def mapsurfacetovolume(data, vertices, res, specialmode, emptyval): """mapsurfacetovolume(data, vertices, res, specialmode, emptyval) Args: data (nd-array): is th...
8463ac67eb7eff381e615ef4dcba94db5fc2688cd2d50203602f8fd6a9d5a218
Python
5,422
150
import SimpleITK as sitk import numpy as np import torch import cv2 import tkinter as tk from tkinter import messagebox from PIL import Image, ImageTk from torchvision.utils import make_grid import torchvision import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1 import ImageGrid from display_gui import load_...
84a5e0029e3e8518d852e5fde535435ecab073641849eda98b9595b8db1ea31a
Python
5,422
138
from typing import TYPE_CHECKING, Tuple import magicgui from magicgui.widgets import request_values from qtpy.QtWidgets import QLabel, QPushButton, QVBoxLayout, QWidget from brainways.project.info_classes import MaskFileFormat, SliceSelection from brainways.ui.widgets.warning_dialog import show_warning_dialog if TYP...
a9fe2cb8f12f64a189693dcffac12a798986f61bf87f52641661edea6b672673
Python
5,422
175
import reprlib from collections import defaultdict from collections.abc import Callable, MutableMapping from functools import partial from inspect import signature from typing import ( TYPE_CHECKING, Any, ) import torch from adabelief_pytorch import AdaBelief from aislib.pytorch_modules import AdaHessian from ...
e638914cd31b8637fab53915337fb19009544a944d07fa249d30f90421a154dc
Python
5,423
106
#!/usr/bin/env python3 import pandas as pd import numpy as np import argparse import os import subprocess import gzip def has_dependency(name): return subprocess.call('which '+name, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) == 0 def patch_bim_ids(bim_in, bim_out): """Modifies long i...
3e0c3e4be84a8512e82d13311c247ee5ff460d0606820ee1d1aa627a980c8ad4
Python
5,424
114
import pandas as pd import numpy as np from typing import Optional from sklearn.base import BaseEstimator as SKLearnBaseEstimator from .survival_utils import safe_join from .regression_curve_fitter import RegressionCurveFitter class UnivariateCurveFitter: def __init__(self, learner: Optional[SKLearnBaseEstimator]...
0aa1831318d7fa539e1c8c698ade78db6ff70895f8d40a7f6d324169681a4ace
Python
5,425
171
#!/usr/bin/python # ## @file # # ctypes interace to a phidgets control library. # # Hazen 12/10 # import time from ctypes import * #class ProductInformation(Structure): # _fields_ = [("axis_bitmap", c_ubyte), # ("ADC_resolution", c_short), # ("DAC_resolution", c_short),...
4b336547f9e419d9f4b5bda671c24bd721658ebff17adbefd9d7e3d7733a71de
Python
5,425
180
import logging import os.path as op from AFQ.utils.path import drop_extension logger = logging.getLogger("AFQ") __all__ = ["Definition", "find_file", "name_from_path"] class Definition(object): """ All Definitions should inherit this. For a given subject and session within the API, the definition is u...
0f2dceb3fcf6a88f400342273cdd28ae839d1135bbc1e61bd5493b0b4657bab9
Python
5,426
127
import abc from abc import ABC from typing import Any, Dict, List, Optional import torch class Scheduler(ABC): """ Parameter Scheduler Base Class A scheduler base class that can be used to schedule any optimizer parameter groups. Unlike the builtin PyTorch schedulers, this is intended to be consistently...
86652ae45505af58e7145ded96a57c2a3f6bcc6bf60daf35a5d1c6c46d1260f1
Python
5,427
157
# Copyright 2025 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, ...
fc055e8a31aeef834357e33c13c1c41adfe52917aca4b3fe70b5abf1cfcd1d5e
Python
5,429
153
import numpy as np import pandas as pd from tqdm import tqdm from typing import Iterable from argclz import int_tuple_type, AbstractParser, argument from neuralib.plot import plot_figure from neuralib.suite2p import get_neuron_signal, sync_s2p_rigevent, Suite2PResult from neuralib.typing import AxesArray from rscvp.ut...
0bf5b0ee1d232a55557cdd8b9d344e86b6fe3ec142eff2508e9481135f13645e
Python
5,430
166
from typing import Any import torch import torch.nn as nn import seisbench.util as sbu from .base import WaveformModel class GPD(WaveformModel): """ .. document_args:: seisbench.models GPD """ _annotate_args = WaveformModel._annotate_args.copy() _annotate_args["*_threshold"] = ("Detection thre...
722057e1958a665ec20803de06db735807690d22381a4c17163cf1e3998d6f59
Python
5,432
167
# 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 from functools import partial from .modeling import ImageEncoderViT, MaskDecoderHQ, PromptEncoder, Sam, Two...
780a650554953d1b84365463394374d9687adc5725a9b20958614e2e65478d1b
Python
5,432
211
#!/usr/bin/python # ## @file # # LDC210 diode laser driver on/off control # # Hazen 04/12 # import sys import time import storm_control.sc_hardware.nationalInstruments.nicontrol as nicontrol ## LDC210 # # Turn on/off with a digital line connected to the # TTL input of the laser diode controller. ...
d4441b61e2353f40b2cfd6520f23e9a083f411cd3437c4f07ce76f3d2be02427
Python
5,432
111
import numpy as np import pandas as pd from typing import Tuple, Union from . import ELA_Network_functions #----------------------------------------------------------------------------------- # ④calc TP for all combinations of SS #----------------------------------------------------------------------------------- #-...
ebe8892fb5778a9457a48116acb498f4582831922e382e0695b7cf9aa81b1b48
Python
5,432
160
""" Classes for working with position specific matrices. """ from copy import copy import numpy from numpy import ( float32, int16, log2, maximum, nan, newaxis, ones, zeros, ) from . import _pwm # type: ignore[attr-defined] class BaseMatrix: """ Base class for position spec...
32f4c8d2e9316af7c0a2c9894550989ec46ae76112a9e8e2b060b3f2a3365f0b
Python
5,433
159
""" HierarchicalEventClassifier_noace @ 2024 Knowblesse Similar to `HierarchicalEventClassifier`. But in this script, I manually remove some neurons from the dataset to test the predictiveness of the model. """ import numpy as np from numpy.random import default_rng from pathlib import Path import sklearn from sklearn....
02b89b1c39d1c4e64d884af25b3d04e015f5406f86da435e1f6a424b30b75f8b
Python
5,434
164
# coding=utf-8 """ Tests for deepreg/dataset/util.py in pytest style """ import h5py import numpy as np import pytest from testfixtures import TempDirectory import deepreg.dataset.util as util def test_sorted_h5_keys(): """ Test to check a key is returned with one entry """ with TempDirectory() as ...
802e8f64495caaa332e273b0f8b2232d6af326c56ad73bec7a7a866b05fae36e
Python
5,434
161
import jax import jax.numpy as jnp import matplotlib.pyplot as plt import glob import sys import os import re import json plt.rcParams["font.sans-serif"] = ["DejaVu Sans"] # Best available plt.rcParams["font.family"] = "sans-serif" plt.rcParams.update({ "font.size": 10, "axes.titlesize": 10, "axes.l...
cc16692906bc34248548698a02642a8da9d38a1b0ab254d30b935af6fb74689d
Python
5,434
151
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Performs an operation on a list of images. The supported operations are listed below. This script is loading all images in memory, will often crash after a few hundred images. Some operations such as multiplication or addition accept float value as parameters instead...
8cb38587a7a5991b8f70e46e1e261dbb7c9259ff5cd2880fdbe5dad9d49d3294
Python
5,438
143
# -*- coding: utf-8 -*- # python standard library inputs import os import random # external inputs import numpy as np import nibabel as nb # local inputs from ..io.get_filename import get_filename from ..cmap.generate_coordinate_mapping import generate_coordinate_mapping from ..utils.apply_affine_chunked import appl...
c67a9247f3bc11293e1fedbc487c2e1b283c50d9aaa0172c989ebbdc73185033
Python
5,438
143
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 ...
4543da232f33887bfe1c7b7e4f070eb0d6b97c31f87f88237d4c9440baa6dd83
Python
5,439
155
"""Local endpoint probes validate URLs without blocking remote providers.""" from contextlib import nullcontext from email.message import Message from io import BytesIO from types import SimpleNamespace from unittest.mock import Mock from urllib.error import HTTPError, URLError from urllib.request import HTTPHandler, ...
c3b618fee5827368547f8df9a3f63a64a02cc6c385f9b036875a18918c120a63
Python
5,439
150
# 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, ...
db5da062c93b3ef17ea9c9af33661768e06116b4bbf5ebc01a0fec3c75e2878c
Python
5,439
145
import json import os from typing import Callable, List, Optional from torch_geometric.data import ( Data, InMemoryDataset, download_url, extract_zip, ) from torch_geometric.io import fs class AirfRANS(InMemoryDataset): r"""The AirfRANS dataset from the `"AirfRANS: High Fidelity Computational ...
c42527365ca729ac44e93edc12f139742e281a02cc1ced669ef8426c3f9cf493
Python
5,442
135
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Script to compute fODF lobe-specific metrics derived from a Bingham distribution fit, as described in [1]. Resulting metrics are fiber density (FD), fiber spread (FS) and fiber fraction (FF) [2]. The Bingham coefficients volume comes from scil_fodf_to_bingham. A lobe...
88726123a9261bf151178090a58881334d1de889f224262634bb9fe7605c47f8
Python
5,443
170
# Copyright 2024 BDP Ecosystem Limited. All Rights Reserved. # # 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 applicab...
e4ab0ccb11d1285994d44f29a86621f4e02e9402e92e026aa13e0419272a8ddb
Python
5,443
156
# py imports import os import sys import glob import time import numpy as np import torch import scipy.ndimage from argparse import ArgumentParser # project imports import networks import datagenerators def Dice(vol1, vol2, labels=None, nargout=1): if labels is None: labels = np.unique(np.concatenat...
1c572cc8e62e79102492887a21fbe08fadd77172a4344de58f85a62af0bd0b9e
Python
5,446
146
from typing import Callable, Optional, Union import torch from torch import Tensor import torch_geometric.typing from torch_geometric.nn.conv import MessagePassing from torch_geometric.nn.inits import reset from torch_geometric.typing import Adj, OptTensor, PairOptTensor, PairTensor if torch_geometric.typing.WITH_TO...