sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
64474fb839b5717612b399ccb53575d6d7803116fa04deee79d40a7c16c5d046 | Python | 1,443 | 29 | import functools
import torchvision.models
import torch
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_preprocess_images
BIBTEX = """@article{geirhos2018imagenet,
title={ImageNet-trained CNNs are biased t... |
b3f12895e5b1161432f3b059f631c80719b9d7a2356a37afa23325db80c382a1 | Python | 1,443 | 39 |
from brainscore_vision.model_helpers.check_submission import check_models
import functools
import torchvision.models
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_preprocess_images
import timm
# This is an ex... |
bf42b5ca4ae981cc8d368df1b55c67f0a3f1254076b374d6f5bdfa454535c09e | Python | 1,443 | 34 | from argclz import AbstractParser
from neuralib.persistence.cli_persistence import get_options_and_cache
from neuralib.util.verbose import publish_annotation
from neuralib.widefield.plot import plot_retinotopic_maps
from rscvp.retinotopic.cache_retinotopic import RetinotopicCacheBuilder
from rscvp.util.cli import Tread... |
e499674498c915fcc3a782f5bcede9bacaf5df52f32847725912bc6cb3abbd9f | Python | 1,443 | 56 | import sys
import numpy as np
import pandas as pd
def remove_marker(potential_genes):
mfn = 'anno.v2.markers.topn.xls'
marker = pd.read_csv(mfn, delimiter='\t')[['group', 'names']]
marker.columns = ['group', 'gene']
for m in marker.gene:
if m in potential_genes:
potential_genes.rem... |
3740c1c8a08463589b70ebb9220fc9b13dc602cd98f3d213df2442ecfc551715 | Python | 1,444 | 36 | # Recursive dictionary merge
# Copyright (C) 2016 Paul Durivage <pauldurivage+github@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 version 3 of the License, or
# (at your o... |
42ac7266b323d5d3ff1c6924ec1efbdc7c43f6ea6ea560271873ebfbea092ae7 | Python | 1,444 | 39 | #!/usr/bin/env python
"""
Emulated AOTF.
Hazen 04/14
"""
import storm_control.sc_hardware.baseClasses.illuminationHardware as illuminationHardware
class NoneAOTF(illuminationHardware.AmplitudeModulation):
def __init__(self, parameters = None, parent = None, **kwds):
super().__init__(**kwds)
#
# The M... |
534fe6d5832b26cf4154b372ea6c4012598e8f81aeddf782ff103156d2b4b611 | Python | 1,444 | 55 | # src/utils/bias_correction.py
import numpy as np
from sklearn.linear_model import LinearRegression
def remove_mean_bias(y_pred: np.ndarray, y_true: np.ndarray):
"""
恒定偏倚校正:将预测值减去平均偏差。
参数
----
y_pred : np.ndarray, shape (n,)
原始预测值
y_true : np.ndarray, shape (n,)
真实值
返回
... |
c4c38af34f53b2f6c5bb837479a323e4916442249f2077a324c895a1eafef190 | Python | 1,444 | 48 | #!/usr/bin/env python3
import genutils3
from optparse import OptionParser
USAGE = """
python get-gaps-bed.py --in <fasta in file> --out <bed file>
Loads sequences from fasta and print out bed of 'N' positions
"""
###############################################################################
parser = OptionPar... |
2647232083c5f848c85998e228ee5d14483a11220ab6a812d29b1fd5cc6edb24 | Python | 1,445 | 37 | #serves both for detection and plotting
import sys
import subprocess
from glob import glob
import os
import yaml
import numpy as np
import pandas as pd
script_det = 'preprocessing/quiet_extraction/run_offperiod_detection.py'
script_plot = 'preprocessing/quiet_extraction/run_offperiod_plotting.py'#'routines/run_offperi... |
c859526edb3b6ce0b72574dd46f3a27ef0f7525291357676d190e47eeeba1cb0 | Python | 1,445 | 47 | import unittest
import numpy as np
import logging
from batchglm.api.models.numpy.glm_nb import Simulator
import diffxpy.api as de
class TestNumericCovar(unittest.TestCase):
def test(self):
"""
Check that factors that are numeric receive the correct number of coefficients.
:return:
... |
d28d67165fc3b903312ddcad73d67ef83ebae244e77deafcc59836880821b9d7 | Python | 1,445 | 45 | import torch
import torch.nn.functional as F
import torch_geometric.graphgym.register as register
from torch_geometric.graphgym.config import cfg
def compute_loss(pred, true):
"""Compute loss and prediction score.
Args:
pred (torch.tensor): Unnormalized prediction
true (torch.tensor): Grou
... |
16ec0f8bc2356088348ce38f1eaf55d9489831da797de1e248608de51d122375 | Python | 1,446 | 34 | #@Context context
#@DatasetService ds
#@DisplayService display
#@ImageJ ij
#@LogService log
#@LUTService lut
#@SNTService snt
#@UIService ui
"""
file:
version:
info:
"""
from sc.fiji.snt import Path, PathAndFillManager, SNT, SNTUI, Tree
from sc.fiji.snt.analysis import GroupedTreeStatistics, MultiTreeStatistics, Nod... |
565a2b11de1d38ccb09bd32dbca74ca12274d5b2a663d11899bd88687d361d4c | Python | 1,446 | 47 |
import sys
import matplotlib.pyplot as plt
import numpy as np
import torch
from PIL import Image
# 添加 unet.py 所在的目录到系统路径
sys.path.append('D:/桌面/project/atomai')
from unet import U_Net # 从 unet.py 中导入 U_Net 类
# 加载模型
model = U_Net(in_ch=3, out_ch=1)
#model = UNet(n_channels=3, out_channels = 1)
model.... |
a7c1e18abb77f6428562b20854e8b1661abba710675ff9345f3f5cec5d0f8650 | Python | 1,446 | 45 | # -*- coding: utf-8 -*-
"""
Sample volume data on surface
The purpose of the following script is to sample data to a surface in native epi
space and map those data to the surface in conformed freesurfer space.
"""
# python standard library inputs
import os
# local inputs
from fmri_tools.mapping.map2surface import m... |
39161f8faadc154f379a2fbd7d97e3f7c71e6ac3682e5e132994bf81360060b7 | Python | 1,447 | 60 | # -*- coding: utf-8 -*-
"""
MPM scaling
This scripts restricts values in a nifti volume to a defined data range. Ceiling
outside are set to the set maximum or minimum value. Optionally, the range is
inverted.
"""
# python standard library inputs
import os
# external inputs
import numpy as np
import nibabel as nb
#... |
45e53af0e70ff19ccc45a0f2a63d05bd180d62ad30ebb0c20304481e7ebcd6c9 | Python | 1,447 | 42 | #!/usr/bin/env python
"""
HAL module for emulating a laser.
Hazen 04/17
"""
import storm_control.hal4000.halLib.halMessage as halMessage
import storm_control.sc_hardware.baseClasses.amplitudeModule as amplitudeModule
class NoneLaserFunctionality(amplitudeModule.AmplitudeFunctionality):
def __init__(self, **kw... |
a0f6b6aebe2f5c5efdbaf127406c51aca90a5041012f79bab99ef721eb0f086d | Python | 1,447 | 39 | import pytest
from qtpy import PYQT5, PYQT_VERSION, QtOpenGL
def test_qtopengl():
"""Test the qtpy.QtOpenGL namespace"""
assert QtOpenGL.QOpenGLBuffer is not None
assert QtOpenGL.QOpenGLContext is not None
assert QtOpenGL.QOpenGLContextGroup is not None
assert QtOpenGL.QOpenGLDebugLogger is not N... |
aafc05563a44931f737bc1e4ef75a6cce32bfe2a3af3425fe4b62f068dfc619a | Python | 1,447 | 47 | import json
import csv
from tqdm import tqdm
import time
import os
import pandas as pd
def generate_userful(num):
start = time.time()
dir_ = './datasets/Twibot-22/'
t = json.load(open(dir_ + 'tweet_{}.json'.format(num)))
length = len(t)
print('Read tweet_{} finish:'.format(num), time.time() - star... |
28a5916f5cb7d3a5e6977a7b47c5358e28ab2127789bd9facef6f0b1e81fb0fe | Python | 1,448 | 58 | #!/usr/bin/env python
"""
Test setting parameters.
"""
from storm_control.test.hal.standardHalTest import halTest
def test_hal_tcp_sp_1():
halTest(config_xml = "none_tcp_config.xml",
class_name = "SetParameters1",
test_module = "storm_control.test.hal.tcp_tests")
def test_hal_tcp_sp_... |
7a473c7804b07f63af3080bcc431b26bb978212c3f8ae34cb13a724ef09e7b56 | Python | 1,448 | 40 | # 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... |
e59a73960da94f4abf268290b3ea9df9c46f67326573b49a9cb94faa2bb7ef85 | Python | 1,448 | 38 | import argparse
from pathlib import Path
if __name__ == '__main__':
# Create CLI argument
parser = argparse.ArgumentParser()
parser.add_argument('--logs_dir', help='Directory containing the slurm logs', required=True)
# Parse CLI logs dir and check if it really exists
args = parser.parse_args()
... |
c43a1e8a811640177c2073c4d5f41400a6e2937a917d2e406576b572781e7deb | Python | 1,449 | 45 | import shutil
import subprocess
import tempfile
from pathlib import Path
import click
import numpy as np
import pydicom
import simple_mri as sm
def read_dicom_trigger_times(dicomfile):
dcm = pydicom.dcmread(dicomfile)
all_frame_times = [
f.CardiacSynchronizationSequence[0].NominalCardiacTriggerDelayT... |
f551359b44d84e8380564694cf7ce1f91a710fb7a70242ba88b09d54dc0d996f | Python | 1,450 | 34 | import os
_report_on = {
'aod pipeline': ['aod_monet', 'aodpre'],
'reso pipeline': ['pre', 'rf', 'trk', 'trippy', 'monet']
}
#--- switch matplotlib backend if there is no way to display things.
cmd = 'python3 -c "import matplotlib.pyplot as plt; plt.figure()" 2> /dev/null'
if os.system(cmd): # if command fai... |
61ec5c880486c523a942aa02f51ba59387998d080e553e7328964132366c6711 | Python | 1,451 | 41 | import ijson
from argparse import ArgumentParser
import os
import json
from tqdm import tqdm
import pandas
if __name__ == '__main__':
parser = ArgumentParser()
parser.add_argument('--dataset_name', type=str)
args = parser.parse_args()
dataset_path = '../../datasets/{}'.format(args.dataset_name)
if ... |
68dd19b0c43ad7ac6fb32f3ec252a75942b8f83459b557b999e6a6a529c3be77 | Python | 1,451 | 69 | #!/usr/bin/env python
import argparse
import sys
numX = 12
numY = 12
numZ = 12
class color:
PURPLE = '\033[95m'
CYAN = '\033[96m'
DARKCYAN = '\033[36m'
BLUE = '\033[94m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
END = '\033[0m'
def getNeighborI... |
fc40e0a56edb72b03d332f33753a774a63d39f7b29d474576b5f97ce5837c62e | Python | 1,452 | 45 | """ Add subdomain tags to a 2D mesh """
import SVMTK as svm
from pathlib import Path
if __name__ == "__main__":
print("Start ",__file__)
outdir = Path("results")
outdir.mkdir(exist_ok=True)
cube = svm.Surface()
sphere1 = svm.Surface()
sphere2 = svm.Surface()
# Edge length of surface mesh
... |
67b3d672ca1a37fc77c6698df7b8e0fda34bfcd224a72897133df301613b78e6 | Python | 1,453 | 38 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import tempfile
from scilpy import SCILPY_HOME
from scilpy.io.fetcher import fetch_data, get_testing_files_dict
# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['processing.zip'])
tmp_dir = tempfile.T... |
6d5d2cbb9d417eec9211b91d501aa16e9c4cada4d3a4252487dfec788f27031b | Python | 1,453 | 56 | from pathlib import Path
import albumentations as A
import torch
from brainways.model.siamese.siamese_backbone import SiameseBackbone
from brainways.model.siamese.siamese_model import SiameseModel
from brainways.model.transforms.normalize_percentile import NormalizePercentile # noqa: F401
def load_model(model_dir:... |
b33024cb76acd27305f225ac1ee475895309464cf622bcb8febef36c7af70690 | Python | 1,453 | 33 | import numpy as np
import pytest
from brainscore_core.supported_data_standards.brainio.assemblies import BehavioralAssembly
from brainscore_vision.benchmarks.objectnet import Objectnet
from brainscore_vision.model_interface import BrainModel
@pytest.mark.private_access
class TestObjectnet:
def test_groundtruth(s... |
c3709175689ca5d02623adf280473491f758c384cf48ea20a2f2a6beef4e5012 | Python | 1,453 | 52 | # coding: utf-8
from pathlib import Path
import pandas as pd
from sklearn.metrics import mean_squared_error
import lightgbm as lgb
print("Loading data...")
# load or create your dataset
regression_example_dir = Path(__file__).absolute().parents[1] / "regression"
df_train = pd.read_csv(str(regression_example_dir / "r... |
5979dbe55d7b013881616b75e5fe58d8f59f9b501d8454a651ab2f9695aa81ed | Python | 1,454 | 39 | # Copyright © 2009- The Spyder Development Team
# Copyright © 2012- University of North Carolina at Chapel Hill
# Luke Campagnola ('luke.campagnola@%s.com' % 'gmail')
# Ogi Moore ('ognyan.moore@%s.com' % 'gmail')
# KIU Shueng Chuan ('nixchuan@%s.com' %... |
a62660f31d2ce12b754a1533c1437cf5c078085ed577231cb4498dcbb7c861e0 | Python | 1,454 | 42 | #!/usr/bin/python
#
## @file
#
# Run misc control only.
#
# Hazen 03/14
#
import sys
import storm_control.hal4000.halLib.standalone as standalone
if (len(sys.argv)==2):
standalone.runModule("misc_control", sys.argv[1])
else:
standalone.runModule("misc_control")
#
# The MIT License
... |
428dbb254228a82f3481bead5df0ea4204b3b9c937755d4c9030451d021b932e | Python | 1,455 | 36 | """Tests for the pure statistics helpers in morphometrics_stats (numpy/pandas)."""
import numpy as np
from surface_morphometrics import morphometrics_stats as ms
def test_weighted_avg_and_std_uniform_matches_numpy():
v = np.array([1.0, 2.0, 3.0, 4.0])
w = np.ones_like(v)
avg, std = ms.weighted_avg_and_st... |
00c9db58431d057c45416bb7836f162c87a5690c9634429b5077c912fc72e2c0 | Python | 1,456 | 43 | # -*- coding: utf-8 -*-
import unittest
import arbor as A
from arbor import units as U
"""
Tests for decor and decoration wrappers.
TODO: Coverage for more than just i_clamp.
"""
class TestDecorClasses(unittest.TestCase):
def test_i_clamp(self):
# Constant amplitude i_clamp:
clamp = A.i_clamp(10... |
c939a9e2e9da8a901a65ff6e1e8fc71e558b14a3d624dce8157c36ae85823909 | Python | 1,456 | 53 | #!/usr/bin/env python
"""
usage: %prog species1,species2,... nrequired < maf
"""
import sys
import bx.align.maf
from bx.cookbook import doc_optparse
SPAN = 100
MIN = 100
def main():
options, args = doc_optparse.parse(__doc__)
try:
species = args[0].split(",")
nrequired = int(args[1])
... |
180427173296373a6c1bf629bad8adf1339f5869d7b49823eca737f65f20f6ef | Python | 1,457 | 48 | """
Tests for `bx.seq.nib`.
"""
import unittest
from bx.seq import nib
test_nib = "test_data/seq_tests/test.nib"
# Same sequence data as stored in test.nib
valid_seq = (
"TGGAGGCATTTGTGATTCAATAGATGCAGAAAGAAACCTTCCTAGAGCTG"
"GCGTTCTCTAACTAAAAGTGGAAAGTTCTGAGGAATGAGGACTGTTATAA"
"ATCCCACCCCACACCGCACCTTCTCC... |
4961f1d3d3b3198efd549b7ff977a0706c6103a77b03df2d80713971da629f0a | Python | 1,457 | 67 | #!/usr/bin/env python
#This script calculate FDR for the P values
import sys,re
def myorder(p,reverse):
p_dict={};
#print('len(p)');print(len(p));
for index in range(len(p)):
if not(p[index] in p_dict):
p_dict[p[index]]=[];
p_dict[p[index]].append(index+1);
#print('p_dict');print(p_dict);
o_index=sorted(p... |
667b6cf8c4c65c380550e8b2e824dd2566392850017525d414c3160f815a744c | Python | 1,457 | 38 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import tempfile
from scilpy import SCILPY_HOME
from scilpy.io.fetcher import fetch_data, get_testing_files_dict
# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['tractometry.zip'])
tmp_dir = tempfile.... |
8d1b1e3874e95b659c4a429e8edd9680d7f244ebbf9fd3cb7d9e6b47f5821702 | Python | 1,457 | 30 | import pandas as pd
from sklearn.ensemble import RandomForestRegressor
import numpy as np
# Load your dataset
data = pd.read_csv(r'H:\data\data.csv',dtype={"tg":float, "ldl": float},encoding='ISO-8859-1',low_memory=False)
# Identify features with missing values
features_with_missing_values = ['plt','wbc','rbc','h... |
9c8b5d8b2dbce23860975c3b8ac272bf8923e0252c169c747762bf6ef05d4d43 | Python | 1,457 | 46 | import numpy as np
import torch
import torchio
from torchio.transforms import Transform
class FlattenImageData(Transform):
def __init__(self, **kwargs):
super().__init__(**kwargs)
def apply_transform(self, subject):
"""
flattens image data of signals image of subject
Args:
... |
515dc2797abdf125dde9801d5e02724f5751f9c4e0a030459de40e520f150b81 | Python | 1,458 | 42 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 20 14:44:13 2024
@author: brainmappers
"""
import sys
subjects_dir=str(sys.argv[1])
subject=str(sys.argv[2])
structure=str(sys.argv[3])
hemi=str(sys.argv[4])
surface=str(sys.argv[5])
number=float(sys.argv[6])
iteration=str(sys.argv[7])
smooth=str(s... |
785d333db1c8312795054b9fd9a7e35cdacc1a5f74a53cea71907803ba2631c2 | Python | 1,458 | 43 | import tensorflow as tf
from tensorflow import keras
from tensorflow.keras.backend import int_shape
def bpnet_seq(inputlen=2114, outputlen=1000, filters=512, ndil=8):
"""
Classic BPNet architecture with sequence-only input. Predicts profile
logits and log-counts.
Inputs and outputs have length inputle... |
edd7a4f911d8929ef42f4ec5d725cb63f32b575f0f8c2d894d8c7f7ed5f8d185 | Python | 1,458 | 35 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import tempfile
from scilpy import SCILPY_HOME
from scilpy.io.fetcher import fetch_data, get_testing_files_dict
# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['connectivity.zip'])
tmp_dir = tempfile... |
027ca94558d1f2ac0b30b7a773f2b65439dc437fa42634c41e1fcf635d56127d | Python | 1,459 | 5 | standard_train_fold=['2iD-tVS8NPw', '8d-gEyoeBzc', 'Qr1Ca94K55A', 'Ci-AH39fi3Y', '8qrpnFRGt2A', 'Bfr499ggo-0', 'QN9ZIUWUXsY', '9T9Hf74oK10', '7JsX8y1ysxY', '1iG0909rllw', 'Oz06ZWiO20M', 'BioHAh1qJAQ', '9c67fiY0wGQ', 'Iu2PFX3z_1s', 'Nzq88NnDkEk', 'Clx4VXItLTE', '9J25DZhivz8', 'Af8D0E4ZXaw', 'TvyZBvOMOTc', 'W8NXH0Djyww',... |
681c5a3fa636a1d618f2dd6f4d711f7fd902fc445b739f19f2fac34ed68773bb | Python | 1,459 | 46 | """# napari Qt demo
Napari provides a few conveniences with magicgui, and one of the
most commonly used is the layer combo box that gets created when
a parameter is annotated as napari.layers.Layer.
The layer box will stay in sync with the viewer model, adding and
removing layers as needed.
This example shows how to... |
811a08b3dae1cc971ffd76b7deeabd2500d16239a132a89f53076c2fddda7934 | Python | 1,459 | 41 | from PyQt5 import QtGui, QtWidgets
from lasagna.plugins.lasagna_plugin import LasagnaPlugin
class IoBasePlugin(LasagnaPlugin):
def __init__(self, lasagna_serving):
super(IoBasePlugin, self).__init__(lasagna_serving)
self.lasagna = lasagna_serving
# Construct the QActions and other stuff r... |
cc9094e73d64d7c1bcc8dd665ac4de28269ea008cc7c52d885cac0a32e6b67e7 | Python | 1,461 | 44 | # 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.
import torch.optim
from . import UnicoreOptimizer, register_optimizer
@register_optimizer("sgd")
class SGD(U... |
e56fabba3e473e04e3e30a1f32a29fc582f3d27df66fb30428e3045481480511 | Python | 1,461 | 50 | import scipy.ndimage as ndi
import numpy as np
def dog(data, sig1, sig2):
# kernel size = 2r + 1 = 8 sigma + 1
data_1 = data
if sig1 is not None:
sig1 = np.array(sig1) if not isinstance(sig1, np.ndarray) else sig1
if np.all(sig1 > 0):
data_1 = ndi.gaussian_filter(data, sig1)
... |
f9709bee4ec97d853e5ce52d0dc2017233be90920b4415bd5c93789911c37bf0 | Python | 1,461 | 51 | import argparse
import os
from pathlib import Path
from scripts.workflow_functions import runSmk
try:
from rich import print
except ImportError: # pragma: no cover - optional dependency for nicer CLI output
pass
def parse_args():
repo_dir = Path(__file__).resolve().parent
parser = argparse.ArgumentP... |
f3d8edad118bd67dc08d0e0217a8a47857da2d47af2659c372ee9057ba5388cf | Python | 1,462 | 38 | """
Merge overlapping regions in two sets of genomic intervals.
"""
from bx.intervals.io import BitsetSafeReaderWrapper
from bx.intervals.operations import (
bits_set_in_range,
MAX_END,
)
# sorting could make this a less memory intensive operation(?)
def merge(interval, mincols=1):
# Handle any ValueErro... |
8084d297524794a24f35150afb87c06efde11d572a6142bc29a4923c9e89495a | Python | 1,463 | 58 | #!/usr/bin/env python
import codecs
import json
import numpy
blocksize = 80
interfacewidth = 7
virtualdomain = [64,128,100]
sphere_center = numpy.array([0,0,1000]) #height = r/2
sphere_radius = 5000
def distance(coord):
return numpy.linalg.norm(coord - sphere_center)
#test all 8 edges with + and -interfacewidth
#i... |
a7b0f5e50acc7c1a920873dc9abb485b74e3adf433c22bdd1bebaca3b4bfd34e | Python | 1,463 | 63 | import sys
sys.path.append("../")
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.feature_extraction.text import TfidfTransformer
from sklearn import decomposition
import jieba
import time
import glob
import sys
import os
import random
if len(sys.argv)<2:
print("usage: extract_topic.py di... |
ac26ec473f85507387434f5588793cd9d90eded73051536b854b515e3b693928 | Python | 1,464 | 36 | # -*- coding: utf-8 -*-
"""
Make visual fieldsign map
The purpose of the following script is to make a visual fieldsign map from
sampled phase-encoded retinotopy data. The script needs an installation of
freesurfer.
"""
# python standard library inputs
import os
# local inputs
from fmri_tools.mapping.vfs import get... |
5cf135230cd225b36b3eb35a8625545ec3c364e8a994a0f0715ff06202ce81f2 | Python | 1,465 | 25 | from nilearn.maskers import NiftiMasker, NiftiLabelsMasker
from nilearn.image import load_img
from nilearn.connectome import ConnectivityMeasure
from nilearn import plotting
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import glob
import os
mask_path = '/mnt/DataDrive3/NishioM/rodent_alcohol/... |
bd18a3ab0834d354d177db1c30ccc64ad3cbb539942e95f51aeee0cc2368359a | Python | 1,465 | 46 | """Sphinx configuration file for the ntac documentation."""
import os
import sys
sys.path.insert(0, os.path.abspath('../../src'))
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/conf... |
eeb175c5f12347cd03599e2ae668bed70d4a48e430688abc167eec8cd6eee417 | Python | 1,466 | 45 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
from __future__ import annotations
from pathlib import Path
import torch
from ultralytics.utils.checks import check_requirements
from .base import BaseBackend
class TritonBackend(BaseBackend):
"""NVIDIA Triton Inference Server backend for re... |
05ed7a5c8cb23b534a35417b878d7071fcc2b945cfbecae4c136ed547cf3f4f2 | Python | 1,467 | 37 | import os
from setuptools import setup
from setuptools import Extension
from Cython import __version__ as cython_version
from Cython.Build import cythonize
from Cython.Distutils import build_ext
bamtools_include = [os.path.abspath('../bamtools/include'),]
bamtools_lib = [os.path.abspath('../bamtools/lib'),]
source_pat... |
63daf4a168856c9edb79935fd4c75872a6a03b74497781827f76f9221fed404f | Python | 1,467 | 45 | import numpy as np
def upscale_ish_volume(
volume,
orig_voxel_size=200,
target_voxel_size=10,
target_volume_shape=(1320, 800, 1140),
rotate_axes=True,
):
"""Upscale a lower-resolution ISH volume for projection.
Parameters
----------
volume : array
Array of ISH expression d... |
054c10b8274eeae63a8206ec7b7a20ff26ce53e99c84db3810023157d064d9e7 | Python | 1,469 | 53 | import matplotlib.pyplot as plt
import pandas as pd
cases = 'Reymond_99_heart_ref3_02'
# plot for the arterial system
models = 'arterial'
elements = ['A5','A1','A8','A52','A49']
title = ['Carotid','Aorta','Radial','Femoral','Anetrior Tibial']
start = [0,1,1,1,1,0]
mmHg_to_Pa = 133.3616
dt = [756-18,756-10,756-63,75... |
2573e0fa6c1782e2126901d12e37dc31e7816ea113864b36bc345b85bccd29d7 | Python | 1,469 | 58 | import pytest
from tests.helpers.run_command import run_command
from tests.helpers.runif import RunIf
"""
A couple of sanity checks to make sure the model doesn't crash with different running options.
"""
def test_fast_dev_run():
"""Test running for 1 train, val and test batch."""
command = ["scripts/train.... |
53c1660bba11a107f7cd80e041758958a9c1c5264d7d93186211e0fa3f15b02b | Python | 1,469 | 46 | """
This module contains functions to plot angles in polar coordinates.
"""
import numpy as np
import json
from utils.LoadSession import findrootdir
def plot_angles(ax, theta, magnitude, color, alpha):
# check if theta is a single number or a list
if not isinstance(theta, list):
theta = [theta]
... |
5e50f1e37adc2ce5bc9af28982446dbf218cbc34f411bc562767ff9d6eec3742 | Python | 1,469 | 47 | import importlib
import click
class LazyGroup(click.Group):
def __init__(self, *args, lazy_subcommands=None, **kwargs):
super().__init__(*args, **kwargs)
self.lazy_subcommands = lazy_subcommands or {}
def list_commands(self, ctx):
base = super().list_commands(ctx)
lazy = sort... |
b2aec1e6ec73ba8a5fd379861c8497fed7a0c03fcf24ad9db782d6f36297cc66 | Python | 1,469 | 46 | """Parity test: Python ssvkernel adaptive KDE vs MATLAB ssvkernel.m.
Ground truth from ``python/test_fixtures/gen_ssvkernel_reference.m`` (MATLAB run
on three fixed PSTH-sample inputs — many/medium/few spikes). ssvkernel is
deterministic for the 3-output call MEA-NAP uses; parity is exact to ~1e-13.
"""
from __future... |
e85cf347c9c6e33c72aec0198e3857f53bd344aed9ffa627da21c1f2e7864fee | Python | 1,469 | 48 | import argparse
from pathlib import Path
import h5py
import numpy as np
import pandas as pd
from tqdm import tqdm
def main(input_path):
np.random.seed(505)
input_path = Path(input_path)
print("Loading metadata")
metadata = pd.read_csv(input_path / "metadata.csv")
# Allows up to ten experiments ... |
371fc9a99004e64b9a0c438f0cdfdb638eaa9012d53f69d240d6035f584e79a2 | Python | 1,470 | 44 | # -*- coding: utf-8 -*-
"""
Created on Fri Apr 11 19:03:57 2025
@author: axthi
"""
import sys
import numpy as np
# --------------------------------------------------
# NOTE: Update this path to fit to your installation
path_to_utils = '/mrhome/axelt/memoslap_utils/memoslap'
sys.path.append(path_to_utils)
import simni... |
3f8fa3e51d8b268dcd457b7eda3a0aed1f3d529305f312c822819c656ec33b76 | Python | 1,470 | 29 | from setuptools import setup, Extension
import numpy
from Cython.Build import cythonize
# from syri import __version__
import glob
setup(name="syri",
# version='{}'.format(__version__),
description='Synteny and rearrangement identifier between whole-genome assemblies',
author='Manish Goel',
aut... |
70c712342ab17a4505e39c1707bd7315c214205762d22a99c38dbcc4c7796952 | Python | 1,470 | 29 | import pytest
from brainscore_vision import load_dataset, load_stimulus_set
@pytest.mark.skip(reason='There is an issue with the packaging where the zip filenames do not match the csv filenames')
@pytest.mark.private_access
def test_assembly():
assembly = load_dataset('Zhang2018search_obj_array')
assert set(... |
ccb768701d791f3d4861db95ca066f1f003d4221bef3e1d12d2ec58ee0888532 | Python | 1,470 | 56 | #!/usr/bin/env python3
import matplotlib.pyplot as plt
import numpy as np
import networkx as nx
import arbor as A
def plot_network(rec, prefix="", graph=True):
fg, ax = plt.subplots()
n = rec.num_cells()
mat = np.zeros((n, n), dtype=int)
ctx = A.context()
net = A.generate_network_connections(rec... |
49af8b94dd682e8cf7befb2320c4f8fada6a745f6d8e56cb80e7b4136492ddb6 | Python | 1,471 | 55 | import torch
import numpy as np
from time import time
import pandas as pd
def unique_torch(tensor):
return torch.unique(tensor)
def unique_npy(tensor):
return np.unique(tensor.numpy())
def unique_pandas(tensor):
np.sort(pd.unique(tensor.numpy().ravel()))
def unique_bincount(tensor):
return torch.whe... |
ffe3c72736572652efd1617deb015230935ed207447ab51d27c7518bcff8302b | Python | 1,471 | 34 | import logging
import os
import sys
# used
def setup_logger(name, filename, level=logging.INFO, logformat ='%(asctime)s %(levelname)s %(message)s'):
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
handler = logging.FileHandler(filename)
handler.setFormatter(logging.Formatter(logformat))
... |
67769066ab4698ff124940436dba3a66449c1792292bbed929f51a002f9459bc | Python | 1,472 | 36 | from brainscore_core.supported_data_standards.brainio.assemblies import NeuronRecordingAssembly
from brainscore_vision import data_registry, stimulus_set_registry, load_stimulus_set
from brainscore_core.supported_data_standards.brainio.s3 import load_stimulus_set_from_s3, load_assembly_from_s3
BIBTEX = """@article{ku... |
0747ff86b1846eecb0cece7099701dcc28d7ca551b226063333df2a43b3a158e | Python | 1,473 | 40 | # Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/... |
d4f1cdb82cbed3044eec56ca933eeb17ed880388555e447d313b51b7ece315ac | Python | 1,473 | 49 | from __future__ import annotations
from dataclasses import fields
from typing import Tuple
import numpy as np
from napari.layers import Image
def update_layer_contrast_limits(
layer: Image,
contrast_limits_quantiles: Tuple[float, float] = (0.01, 0.98),
contrast_limits_range_quantiles: Tuple[float, float... |
30364b20ed2b8b473411ed882c391c1e4a7c2c4d8ac9d862729db886173f1e3f | Python | 1,474 | 63 | # -*- coding: utf-8 -*-
"""TODO"""
import numpy as np
class Connection:
"""TODO"""
def __init__(self, source, destination, transmitter, name="Connection"):
"""TODO"""
self.source = source
self.destination = destination
self.transmitter = transmitter
self.name = name
... |
97c90003717ac54bc1eb24e1d891457dbaa29ae2b86834e42bbe17c6a0a0f8a9 | Python | 1,474 | 59 | import numpy as np
from impedancefitter import get_equivalent_circuit_model
from impedancefitter.randles import Z_randles, Z_randles_CPE
omega = 2.0 * np.pi * np.logspace(1, 8, num=20)
# for randles
Rct = 100.0
Rs = 100.0
Aw = 10.0
C0 = 1e-6
# for randles_CPE
k = 1e-5
alpha = 0.6
model1 = "R_s + parallel(R_ct + W,... |
f1638ba3845a0845384d1043f9ade8eeb421e52cd66354a86fcbad2e757a9061 | Python | 1,474 | 55 | import torch
import pytest
from mlcg.data import AtomicData
from rangemp.nn.utils import calc_weights, calc_weights_pbc # adjust import as needed
def get_dummy_data(one_mol=False):
pos = torch.tensor(
[[1.1, 2.2, 0.3], [0.4, 0.2, 0.0], [0.1, 0.8, 0.5], [0.3, 1.7, 0.6]],
dtype=torch.float32,
)... |
c8841f01b8551daaa5dc7baf0e43f769ace68f3dacde7f6eb95613a6f970c22c | Python | 1,476 | 46 | # -*- coding: UTF-8 -*-
# Copyright (c) 2019 PaddlePaddle Authors. 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
#
... |
3ba7be0377a54f7b1e74f67e5e8c2d556d7c0dfb49a7a88c88208415b7e3e627 | Python | 1,477 | 47 | stylesheet = """
/* Add a border to the top-level window */
QMainWindow{
border: 0px solid black; /* Set border color and thickness */
border-radius: 10px; /* Optional: Add rounded corners */
}
/* Add a border to QDialog windows */
QDialog {
border: 2px solid black; /* Set border color and thickness */
... |
5a9c1a946d67a20b29b8cdeb0c00c8c833d16b1ff2c051ea8c227300e548805f | Python | 1,478 | 48 | '''VGG11/13/16/19 in Pytorch.'''
import torch
import torch.nn as nn
cfg = {
'VGG5': [64, 'M', 128, 'M', 256, 'M'],
'VGG11': [64, 'M', 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'],
'VGG13': [64, 64, 'M', 128, 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'],
'VGG16': [64, 64, 'M', 128, ... |
f80f4515fe7523ccf2ac14c9ba467289d0e0bf7c26cad51eec228e9b9d3951bf | Python | 1,478 | 57 | import sys
from typing import ClassVar
if sys.platform == 'linux':
import os
os.environ.setdefault('JOBLIB_START_METHOD', 'spawn')
import joblib
import polars as pl
from argclz import argument, validator
from neuralib.util.verbose import fprint
from .cli_output import DataOutput
__all__ = ['MultiProcOption... |
fd3be9ca7142dec25dbc611d52e96733f6ba2c7ec1487e3dc32f34bbbfd0d52e | Python | 1,478 | 43 | # 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 typing import Type
class MLPBlock(nn.Module):
def __init__(
self,
... |
0b061c47d5c7be394d4fb170ac361e0a4256e6037a3b62bd1525be1397a93f85 | Python | 1,479 | 39 | import time
class RuntimeMetering:
def __init__(self):
self.start()
def start(self):
"""
Set the start of runtime metering
"""
self.metering_checkpoints = {} # initialize dictionary of time metering checkpoints
self.metering_start_time = time.time()
self... |
6f83f3433a85831c5e83b18ee8d876e63211820beee30329e491230c3eb1ebf3 | Python | 1,479 | 40 | from fancyimpute import Solver, SimpleFill
from low_rank_data import XY, XY_incomplete, missing_mask
from common import reconstruction_error
import numpy as np
import warnings
def test_prepare_input_data():
_solver = Solver()
print(_solver) # for improved coverage
# test that a complete matrix returns a... |
952618d4eae691401ab799553004bf5fd37fd04e9d0f35aa10ac9cd65ea56ef1 | Python | 1,479 | 47 | import numpy as np
import nibabel as nib
import matplotlib.pyplot as plt
# ----------------------------
# 1. Load skeletonized MD image
# ----------------------------
nii_file = r"F:\BIDS\WCH_AF_Project\derivatives\dwi_pipeline\sub-AFib0241\ses-baseline\psmd\MD_skeletonized_masked.nii.gz" # replace with your file pat... |
bb3e391936b00b9cfb052417d7bc2000617fcb6de1e934026a3f771633f932f3 | Python | 1,479 | 76 | """
This module implements fast fourier transform
Author:
Zhengguo Tan <zhengguo.tan@gmail.com>
"""
import torch
from torch import Tensor
from typing import Tuple
__all__ = [
"fft",
"ifft",
]
def _normalize_dims(dims, ndim):
if dims is None:
return tuple(range(ndim))
else:
ret... |
2b34e41c6b604122139aa2ccd942cb7b56ddda54d3b7f563052f16674156bb3f | Python | 1,480 | 41 | #!/usr/bin/env python
"""
Emulated daq card.
Hazen 04/14
"""
import storm_control.sc_hardware.baseClasses.illuminationHardware as illuminationHardware
class NoneDaq(illuminationHardware.DaqModulation):
"""
Daq card emulation.
"""
def __init__(self, parameters = None, parent = None, **kwds):
... |
c8ebfbf7a4d8da468e2bfeaa29e7d7d33d475c099ce139b5eec5e918cdf3b5ed | Python | 1,480 | 21 | """Create one immutable, pre-results plan snapshot; never refresh silently."""
import json
from datetime import datetime,timezone
from src.acquisition.download import ROOT,sha256
def main():
dest=ROOT/'provenance/analysis_freeze.json'
if dest.exists():raise ValueError('Freeze already exists; record an explici... |
1c06acb58af92622a532bebfbf69f0e3c66336380ab475a4310279ab537876ca | Python | 1,481 | 63 | """Calculate static spectra.
Note: the static.welch_spectra function can be substituted below
to use Welch's method for calculating spectra.
"""
import os
from osl_dynamics.data import Data
from osl_dynamics.analysis import static
def get_data(name, rename):
os.system(f"osf -p by2tc fetch data/{name}.zip")
o... |
57ffd7a87073919166d4dcbf9fbe980fc92c4d067459cf67c9b6f77acd676504 | Python | 1,481 | 44 | from tomocupy_stream import GPURecRAM
from tomocupy_stream import find_center
import numpy as np
import tifffile
import time
in_dtype = "uint8" # input data type
dtype = "float32" # output data type
n = 2048 # sample size in x
nz = 2048 # sample size in z
nproj = 2048 # number of projection angles
ndark = 10 # ... |
831d0ba7972f83d0b5e875769efbd8c4a71d6d10789b4ec9fcabe1fc68d107ae | Python | 1,481 | 49 | # Copyright (c) 2022, Hyewon Jeong, Kwanhyung Lee. All rights reserved.
#
# Licensed under the MIT License;
# you may not use this file except in compliance with the License.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS... |
ad95e9fb0e702d9d60b942b9b60fe2e191788de8b803881d08b4241fd4864fc1 | Python | 1,481 | 36 | # Created by David Coggan on 2024 06 23
from brainscore_core.supported_data_standards.brainio.assemblies import BehavioralAssembly
from brainscore_vision import (
stimulus_set_registry, data_registry, load_stimulus_set)
from brainscore_core.supported_data_standards.brainio.s3 import (
load_assembly_from_s3, lo... |
d1114082f73f57879a0513b5517238c891f3eabf07e6f8524824b320d5eccc2e | Python | 1,481 | 43 | # 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 typing import Type
class MLPBlock(nn.Module):
def __init__(
self,
... |
f7a24da6bcb2561b9a404f9f2bcec92146782ff08e74c8f9f39828306ee6f3a8 | Python | 1,481 | 41 | #!/usr/bin/env python
"""
Emulated laser.
Hazen 04/14
"""
import storm_control.sc_hardware.baseClasses.illuminationHardware as illuminationHardware
class NoneLaser(illuminationHardware.AmplitudeModulation):
"""
Laser emulator.
"""
def __init__(self, parameters = None, parent = None, **kwds):
... |
1c61d75fe091192e4d0d65ba029ee8f84293654cc58826b6e154ff9053e4e7ac | Python | 1,482 | 55 | import click
from matplotlib import pyplot as plt
import numpy as np
import pandas as pd
from cycler import cycler
purple = [.5, 0, .5, 0.9]
purple_light = [.5,0,.5, 0.3]
green = [0, 1, 0, 0.9]
green_light = [0,1,0,.3]
colors = [purple,green]
colors_light = [purple_light, green_light]
@click.command()
@click.argumen... |
293b640b27eb3a12f01fbbf0b3b93bc6c86412a7a476b10667eae612bc92bdc4 | Python | 1,482 | 50 | from copy import deepcopy
__all__ = ['get_img_extensions', 'is_img_extension', 'set_img_extensions', 'add_img_extensions', 'del_img_extensions']
IMG_EXTENSIONS = ('.png', '.jpg', '.jpeg') # singleton, kept public for bwd compat use
_IMG_EXTENSIONS_SET = set(IMG_EXTENSIONS) # set version, private, kept in sync
de... |
09bf4e355e574a366c82b2658d589ad5a7572a94dc31078fd8b8779507865185 | Python | 1,484 | 51 | #!/usr/bin/env python3
import arbor as A
from arbor import units as U
from util import plot_spikes, plot_network
from unconnected import unconnected
# global parameters
# cell count
N = 125
# total runtime [ms]
T = 100
# numerical time step [ms]
dt = 0.1
class brunel(unconnected):
def __init__(self, N) -> None... |
133045b676e6f4619c91ebdd2227d313944308f7b43083fae4fbb77988460f9f | Python | 1,484 | 54 | import unittest
import os, sys
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../../")))
from heig.utils import find_loc
def find_window(positions, start, end):
"""
Get index of a window [start, end)
"""
start_idx = find_loc(positions, start)
end_idx = find_loc(posi... |
5a27b4ca4efe25d5208ca0058042e5f1672dd4b28d87f779394f7ee991a80be4 | Python | 1,484 | 64 | from pathlib import Path
import click
from tqdm import tqdm
from brainways.project.brainways_project import BrainwaysProject
from brainways.utils.cell_detection_importer.keren_cell_detection_importer import (
KerenCellDetectionsImporter,
)
@click.command()
@click.option(
"--project-path",
type=Path,
... |
a297df2bff659fe05bf5e3cf9d4437ea551feac345133ac225976c363918ee9d | Python | 1,484 | 39 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import tempfile
from scilpy import SCILPY_HOME
from scilpy.io.fetcher import get_testing_files_dict, fetch_data
# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['bundles.zip'])
tmp_dir = tempfile.Temp... |
2884f5b683030cc210a17883de5de7f3ea3537c7af3c172d1734fb79118a0ea9 | Python | 1,485 | 36 | # Ignore some warnings
import warnings
warnings.filterwarnings("ignore", message=r".*invalid escape sequence '\\<'",
category=SyntaxWarning)
warnings.filterwarnings("ignore", message=r"invalid value encountered in divide",
category=RuntimeWarning, module=r".*bct\.algorit... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.