sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
ed455b13b98b1dd3b9ba54cab30863b1e841610ad8346d689e02ba40a495396b
Python
1,078
37
""" Run a rest API exposing the yolov5s object detection model """ import argparse import io import torch from PIL import Image from flask import Flask, request app = Flask(__name__) DETECTION_URL = "/v1/object-detection/yolov5s" @app.route(DETECTION_URL, methods=["POST"]) def predict(): if not request.method ...
1c50dd7ad0ed0ffe0bb6329c5de3dfacfc27c4f2d67fb3167a7d4fd0961accb2
Python
1,079
30
#!/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=['bst.zip']) tmp_dir = tempfile.Temporar...
952186976f89627adcb457c9496e9f1d08e3b562f9a87832b326e76d2993fc4e
Python
1,079
29
from enum import Enum, IntEnum class PreprocessorSteps(IntEnum): INPUT = 0 COREGISTERED = 1 ATLAS_REGISTERED = 2 ATLAS_CORRECTED = 3 N4_BIAS_CORRECTED = 4 BET = 5 DEFACED = 6 class Atlas(str, Enum): BRATS_SRI24 = "brats_sri24.nii" """Slightly modified SRI24 atlas as found in the ...
a1edbc643431a04076e9a649e3468f4da03eea67a2341dfb8db3e2d998d8138f
Python
1,079
35
"""Test for QtHelp namespace.""" import pytest from qtpy import PYQT5, PYQT_VERSION, QtHelp def test_qthelp(): """Test the qtpy.QtHelp namespace.""" assert QtHelp.QHelpContentItem is not None assert QtHelp.QHelpContentModel is not None assert QtHelp.QHelpContentWidget is not None assert QtHelp.Q...
ae44876d4f637094465d466435f7d8d9ccfb4abfe4afed49ff3d3448c3bd8d08
Python
1,079
33
import os from impedancefitter.utils import draw_scheme # those were used for testing the code # they do not work with LMFIT!!! # they were just there to check that everything is alright working = [ "R + C + L + CPE", "RC + R + parallel(R, C) + parallel(R, C)", "parallel(R + R, C + C)", "parallel(R, ...
468b980e4f886f64c7383aa73fb3d3d95c95618253c7d414d3cdae0fa95dd0e7
Python
1,080
27
from bism.backends.unet import UNet_2D, UNet_3D from bism.backends.unext import UNeXT_2D, UNeXT_3D from bism.backends.r_unet import RUNeT_2D, RUNeT_3D from bism.backends.cellpose_net import CPnet_2D, CPnet_3D from bism.backends.unetplusplus import UNetPlusPlus_3D, UNetPlusPlus_2D import torch.nn as nn import torch __...
3d8c756b6d310ae8bd334a0af4b486502763608b2ed3e1bd411ad0250ad7069f
Python
1,081
50
#!/usr/bin/env python """ Read two lists of intervals (with chromosomes) and count the number of entries in the second set that intersect any entry in the first set. TODO: This could use bitsets rather than the intervals package, would it be faster? usage: %prog bed1 bed2 > out """ import sys from bx import ...
ad11ed212ecc5b0f85da5da67a326f362d795c3dbaae59d8da1fc46b6f59de2a
Python
1,081
41
#!/usr/bin/env python3 import sys from optparse import OptionParser USAGE = """ convert-dustout-to-bed.py --sddust <sddust file> --bed <output file>s convert output of SDDust to bed format """ ############################################################################### parser = OptionParser(USAGE) parser.add...
beef6d1dccdf9d8877a33de1d7b9ab69b922abd1ace48f47979413a3f4587905
Python
1,081
49
import os # Model MODEL_NAME = 'swin-unetr' # Classes ORGANS = ['glomeruli'] NUM_CLASSES = len(ORGANS) + 1 # +1 for background # CZI Path PROJECT_PATH = 'kidney_swinunetr' DATA_PATH = '/hdd/yang/projects/glomeruli_segmentation/data/high-res_training/' # CS Cluster # PROJECT_PATH = '/home/zhouyang/kid...
e05013cb8695f298d4decc14140c81a34001d15f70685749d68684c471afb370
Python
1,081
36
""" calculate spearman's cor """ import sys import numpy as np import pandas as pd import scipy.stats from util import get_max_of_dict, get_min_of_dict, read_list, read_expr import matplotlib.pyplot as plt from itertools import product from filter_gene import * if __name__ == '__main__': wt_expr = pd.read_csv(sys...
28998d9433956051b434e65bb370e6abc550cbb0d6bbd4d606d46478aa3b96ba
Python
1,083
45
# -*- coding: utf-8 -*- """ Provides simple formatting tools to print text with parallel process header """ #:copyright: Copyright 2015 by Christoph Kirst, The Rockefeller University, New York City #:license: GNU, see LICENSE.txt for details. import sys class ProcessWriter(object): """Class to handle writing fr...
30d020ef94b9081e26a46d06cd6394ff5b899d1f1b2c9a64a9b52fe47ec051ef
Python
1,083
31
# -*- coding: utf-8 -*- """ Created on Wed Nov 6 21:32:30 2019 @author: Yoshi """ import numpy as np from joblib import Parallel, delayed from scipy.ndimage import gaussian_filter,gaussian_filter1d def xyz_gaussian_filter(folder_images,x_sigma,y_sigma,z_sigma): # Goes through each image and applies a 2D ...
bf840582111de86f63eb3f930ec9f8bed03b465fdee14ea16dedf2ca8f33991b
Python
1,083
40
import exp_utils import pandas as pd import os import math import numpy as np "Script to prepare possible positions for the 20 dot stimulus. To be read in later during the experiment to reduce computation time" cond = 'constarea' shape = 'dot' vf_radius = 0.75 num = 20 # total area that will be maintained over all ...
d8527f0546b0cead43e5f3ab6a956a2c77eaa8e6d6931e8d4bd00640b9990a8f
Python
1,084
33
import subprocess import sys import yaml script_unit_couting = 'dataset_general/unit_counts.py' script_feature_correlations = 'dataset_general/feature_correlations.py' script_paraminteraction = 'dataset_general/parameter_interactions.py' scripts = [script_unit_couting,script_feature_correlations] scripts = [script_pa...
f82818e8a2b947681e1daba4fe09097499ed1d4dd31a187984390dbb7d0a5683
Python
1,084
35
""" Creating 2D mesh using constraints """ import SVMTK as svm import numpy as np from pathlib import Path if __name__ == "__main__": print("Start ",__file__) outdir = Path("results") outdir.mkdir(exist_ok=True) slc = svm.Slice() # Hexagon radius r = 8 # Edges of a hexagon hexagon =...
efd7ac72dbc8edd4c2df06dbb84b5d2fc047713f54a9e31c4672760df9f32c81
Python
1,085
37
# Copyright (C) CVAT.ai Corporation # # SPDX-License-Identifier: MIT from django.core.management.base import BaseCommand from cvat.apps.engine.models import Task from ..utils import move_multiple_tasks, parse_task_ids class Command(BaseCommand): help = "Moves data of a given task from backing cloud storage bac...
386168a5e1985a130711a5a106dcb147021c1dafca43e6ec032fd7aa51a55926
Python
1,086
37
import tkinter as tk from tkinter import filedialog import pandas as pd import matplotlib.pyplot as plt def open_file(): # show dialog to select CSV(acceleration) file file_path = filedialog.askopenfilename( title="Select CSV(acceleration) file", filetypes=[("CSV Files", "*.csv"), ("All Files",...
4a90035633820a85096904ab4201010f25b960cfe797eb080a32adffa45c4ab0
Python
1,086
39
# -*- coding: utf-8 -*- """ Created on Wed May 10 19:18:46 2017 """ import numpy as np #### Assess purity of a graph def get_purity(node,neighbors,colors): l=len([i for i in range(len(neighbors)) if colors[neighbors[i]]==colors[node]]) #return l*1.0/len(neighbors) return l def compute_overall_purity(node...
d25447095c4580c0ef9f167e483264df69daedbba94c653c8a124ddfb94d8db8
Python
1,086
39
#!/usr/bin/env python """ Hand run tests, not designed for CI as they will take a while to run. """ from storm_control.test.hal.standardHalTest import halTest def dave_sequence(): halTest(config_xml = "none_tcp_config.xml", class_name = "StandardDaveSequence1", test_module = "storm_contr...
1819b8c193a8d0d058bfcac09c43098c8e58bdb23cce68c2568db14c77e49086
Python
1,087
31
#!/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=['filtering.zip']) tmp_dir = tempfile.Te...
51c5aca76421453cb2880648b542e913b870ca8434f663c30e042193db9c1f2f
Python
1,087
36
from __future__ import annotations import random from dataclasses import replace import numpy as np from brainways.pipeline.brainways_params import BrainwaysParams, TPSTransformParams def randomly_modified_params(params: BrainwaysParams): modified_atlas = None modified_affine = None modified_tps = None...
90b134a0b32e7787cc158c6e8f13502887d2d27a92df21f26b1d4fdb8460e893
Python
1,087
41
# -*- coding: utf-8 -*- from ast import literal_eval from configparser import ConfigParser from argparse import Namespace class Config(ConfigParser): def __init__(self, path): super(Config, self).__init__() self.read(path) self.namespace = Namespace() self.update(dict((name, lit...
a1efbc2b3ed418dca55b0e8adb29e9afcc1e0ffbcb9a4f19c17ffe6dced645d5
Python
1,087
37
__mindtibval__ = 0.5 # minimum DTI B-value __maxdtibval__ = 1.5 # maximum DTI B-value __mindkibval__ = 0.5 # minimum DKI B-value __maxdkibval__ = 3.0 # maximum DKI B-value __minfbibval__ = 4.0 # minimum FBI B-value __maxfbibval__ = 12.0 # maximum FBI B-value __d0__ = 3.0 # diffusivity of free water at body temp ...
b795447f22e70485a343d4ae8581f0256189448dbed2a28329bcd3701dfee249
Python
1,087
29
''' PI voltage Z module Alistair Boettiger, 07/19 adapted from Ludl (voltage controlled) Z stage functionality, George 02/18 not currently implemented -- it looks like I get all I need from mclVoltageZModule possibly update for aesthetic quality later on. ''' from PyQt5 import QtCore import storm_control....
fe584e34d0d1bd3d0f6135ba7bfb0b1fb7ce68d20c143c9e906cdcda6fb86e87
Python
1,087
35
# This file is part of connectome-manipulator. # # SPDX-License-Identifier: Apache-2.0 # Copyright (c) 2024 Blue Brain Project/EPFL import os import pytest from bluepysnap import Circuit from utils import TEST_DATA_DIR from connectome_manipulator.connectome_manipulation.manipulation import Manipulation from connecto...
afa154e4cff9b987072a20411ee7842cd455dc1632f2ddd269d121bc207412ba
Python
1,088
32
#!/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=['tracking.zip']) tmp_dir = tempfile.Tem...
e88c04216934601a9731071539615f35f6a58dc97d01a77f509e6ed1736d0cd6
Python
1,088
38
import unittest import os, sys sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../../"))) from heig.wgs.gwas import parse_ldr_col class Test_parse_ldr_col(unittest.TestCase): def test_good_cases(self): target = (0, 3) input_string = "1:3" self.assertEqual(target,...
4e06bb2c44b41f88e861646651b77f81d2d5abfc261162c9056fe9ec9e911d30
Python
1,089
36
# Copyright (C) 2020-2022 Intel Corporation # # SPDX-License-Identifier: MIT import json import base64 from PIL import Image import io from model_handler import FaceDetectorHandler, AttributesExtractorHandler def init_context(context): context.logger.info("Init context... 0%") # Read the DL model conte...
c02bb14844329cf8782d0da1acc99e55d42839c8e88e8716d733f02462400f2b
Python
1,089
42
# -*- coding: UTF-8 -*- from __future__ import unicode_literals import sys import os sys.path.append("../") from whoosh.index import create_in from whoosh.fields import * from whoosh.qparser import QueryParser from jieba.analyse import ChineseAnalyzer analyzer = ChineseAnalyzer() schema = Schema(title=TEXT(stored=Tr...
2904063d722a30b6d98b44c3ddc3498152f1334aaa7e5a85ce8b47a07f30d792
Python
1,090
26
from dtiplayground.dmri.common.tools.base import ExternalToolWrapper class BRAINSFit(ExternalToolWrapper): def __init__(self,binary_path= None, **kwargs): super().__init__(binary_path, **kwargs) def affine_registration(self, fixed_path, movi...
8c9e6c13547e6bfbb09c9f8b8d795f813d975cfc944d29bf337118133c269ed1
Python
1,090
35
from unittest.mock import MagicMock from brainways.project.info_classes import ( BrainwaysParams, MaskFileFormat, SliceSelection, ) from brainways.ui.controllers.cell_detector_controller import CellDetectorController def test_enabled(): params = BrainwaysParams() enabled = CellDetectorController....
f4880db3e2c53f7766a5a3fca65923ff311be768093ad5c23f775df180cf992c
Python
1,090
28
# -*- coding: utf-8 -*- from scilpy.tests.dict import (dict_to_average, expected_dict_averaged, dict_1, dict_2, expected_merged_dict_12, expected_merged_dict_12_recursive, expected_merged_dict_12...
17b31bae94e60674236e8b5963ac75b426247d95884f461fea6164dcbcda3add
Python
1,091
31
# Copyright (c) OpenMMLab. All rights reserved. import logging from mmcv.utils import get_logger def get_root_logger(log_file=None, log_level=logging.INFO, name='mmcv'): """Get root logger and add a keyword filter to it. The logger will be initialized if it has not been initialized. By default a StreamH...
72cecf06bad73f17183a36867474e6655171d3d4333b24888ace98c8b2198d7a
Python
1,091
40
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## # # See COPYING file distributed along with the gradunwarp package for the # copyright and license terms. # ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## import logging VERSION = '2.0.0alpha' usage = ''...
0e235665bebdfb592bfe4128c6fd45a0aeaf6181dfe5700632adcfb278f5b4f4
Python
1,092
43
# -*- coding: utf-8 -*- # python standard library inputs import os # external inputs import nibabel as nb def volume_threshold(file_in, prefix, data_max): """Volume threshold. Takes a nifti volume and sets a maximum threshold value. All values above the threshold are replaced by the threshold valu...
92f3ac3b36771a349628f6d81623321d617aec92f6a1c75801454e60f0b2a794
Python
1,092
38
from model_architectures import Generator import nibabel as nib from tensorflow import convert_to_tensor from tensorflow.config import list_physical_devices import numpy as np ##########INPUTS############## mri_paths = # TO DEFINE dest_paths = # TO DEFINE weights_path = './iguane_weights.h5' ############# if len(lis...
acc1fb2775dd64706a6a20173d9d7289f7a57b5cf67d6e2dea9970b0df1325d5
Python
1,092
29
# Copyright (C) 2018-2022 Intel Corporation # # SPDX-License-Identifier: MIT from django.conf import settings from django.http import HttpResponsePermanentRedirect from drf_spectacular.utils import extend_schema from rest_framework import status, viewsets from rest_framework.decorators import action from rest_framewor...
0b2b1ad174012c6744c31230f9d1e133a3c8ad93dd2723bbaa5f2a32ad7842dd
Python
1,093
30
#!/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...
2b1491519f76c4d931965ff8ffcf44b33e32b1dc07b2565549e60732586853a7
Python
1,093
40
from types import SimpleNamespace import numpy as np from napari_dmc_brainmap.results.probe_vis.probe_vis.view.ProbeVisualizer import ( ProbeVisualizer, ) def test_organize_probe_keeps_coordinates_signed(): visualizer = SimpleNamespace( probeDict={ "probe": { "Voxel": [[0...
7dc5236c60502696e40f64a148c82c69f357d87644e030f5ecf8e455e999f202
Python
1,093
33
#!/usr/bin/env python """ HAL module for emulating an emission filter wheel. Hazen 04/17 """ import storm_control.hal4000.halLib.halMessage as halMessage import storm_control.sc_hardware.baseClasses.filterWheelModule as filterWheelModule class NoneEMFilterWheelFunctionality(filterWheelModule.FilterWheelFunctionali...
91226a0a961d609e4ce693850cea265f297c1e196a3733636e178779d5f4257f
Python
1,093
50
# -*- coding: utf-8 -*- # python standard library inputs import os def get_filename(file_in): """Get filename. This function gets path, file name and file extension for an input filename. The loop checks for some given extension names. Otherwise it stops after the last found dot in the string. ...
76307219cf51728012695883fd7542327c182be85b53842328b20a82debbc3ac
Python
1,094
36
import nibabel as nib import pandas as pd import numpy as np from tensorflow import convert_to_tensor from tensorflow.config import list_physical_devices from model_architecture import Model #########INPUTS######### mri_paths = # to define ids_dict = # to define def intensity_norm(mri): # to define def activation(ou...
4c64dfff6947d1500303b28e0f4444eed3c3c132fc325943c6aa66dbc2d85db6
Python
1,095
37
# Resume all interrupted trainings in yolov5/ dir including DDP trainings # Usage: $ python utils/aws/resume.py import os import sys from pathlib import Path import torch import yaml sys.path.append('./') # to run '$ python *.py' files in subdirectories port = 0 # --master_port path = Path('').resolve() for last ...
ac41941feadb28dc806de423ba98f9136727f5af8411244df66d19acd6cef06b
Python
1,095
41
import nibabel as nib import sys import argparse import numpy as np def argument_parse(argv): parser=argparse.ArgumentParser(description='Print dimensions for input volume or multiple input volumes') parser.add_argument('volumefile',nargs='*',action='store',help='one or more input volumes (eg: .nii files...
d67685a9f0eca2ffd5e13f2c2d4d51f2865f425df2a4e1196e4e57a945202693
Python
1,095
41
#!/usr/bin/env python """ Test setting progressions. """ from storm_control.test.hal.standardHalTest import halTest def test_hal_tcp_sp_1(): halTest(config_xml = "none_tcp_config.xml", class_name = "SetProgression1", show_gui = True, test_module = "storm_control.test.hal.tcp_te...
0e6436747a456a90f58de8170e4b759d37c075c8c4d0a936ad9f06de012f5870
Python
1,096
36
class debugtest: """ A class to store molecular data and corresponding calculations for debugging and testing purposes. Attributes ---------- molecules : list[str] List of molecule identifiers used in test calculations. exp_values : dict[str, float] Dictionary mapping test iden...
30d6f9006589839f30219e966a5c55f82bd777e7cd943dd8e772d83c3d19933e
Python
1,096
38
# -*- coding: utf-8 -*- from collections.abc import Iterable from flair.parser.utils.common import unk class Vocab(object): def __init__(self, counter, min_freq=1, specials=[]): self.itos = specials self.stoi = {token: i for i, token in enumerate(self.itos)} self.extend([token for token...
6a4c4667907f39a2e112263b906b05ea958f1e9f5a409ead5187dccd0f81a599
Python
1,096
27
import nibabel as nib import numpy as np import os def remove_region_from_mask(mask_path, dk_path, output_path, region_value=1): # Load the binary mask and DK atlas mask_img = nib.load(mask_path) mask_data = mask_img.get_fdata() dk_img = nib.load(dk_path) dk_data = dk_img.get_fdata() # Set ma...
7daea2081e495455e0a6ec97af34e0e7146f59ccc2271cf3c893e3234a133125
Python
1,096
38
# ----------------------------------------------------------------------------- # Copyright © 2009- The Spyder Development Team # # Licensed under the terms of the MIT License # (see LICENSE.txt for details) # ----------------------------------------------------------------------------- """Provides QtNetworkAuth class...
e0cd8f9fb886dbf286634e015f6a9aa5e220b1dbf90a260397922cfbaa6fb600
Python
1,096
30
#!/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...
2017c8dbcbac70d98eb0d1ad6a76e4172c79f4b9a013c3c9d79e383cb63d9558
Python
1,097
36
# 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. """isort:skip_file""" import os import sys try: from .version import __version__ # noqa except ImportErro...
3fb669f938f6737c88bde75c95962e7e76ec0153fb8b5e931d54534816b5045d
Python
1,098
35
import os import unittest from PUMI.engine import BidsPipeline from PUMI.engine import NestedWorkflow from PUMI.engine import NestedNode as Node from nipype.interfaces.fsl import Reorient2Std from PUMI.pipelines.func.deconfound import despiking_afni project_root = os.path.dirname(os.path.abspath(__file__)) class Tes...
4faa1f207bb3f25898e1619bf334b7aa9e9e759a8bb710dc15ffcda46e9e9e30
Python
1,098
35
import pandas as pd from rdkit import Chem from rdkit.Chem import AllChem from rdkit import DataStructs import numpy as np # Read CSV file file_path = './2.construct_network/drug_smiles.csv' df = pd.read_csv(file_path) # Extract CID and SMILES cids = df['drug_cid'].tolist() smiles_list = df['smiles'].tolist() # Con...
b7c6a8fa05675f37faf0444c7bcd235b797c514633a5bcad803646c469fc2831
Python
1,098
35
import os from PUMI.engine import BidsPipeline from PUMI.pipelines.func.deconfound import despiking_afni ROOT_DIR = os.path.dirname(os.getcwd()) input_dir = os.path.join(ROOT_DIR, 'data_in/pumi-unittest') # path where the bids data is located output_dir = os.path.join(ROOT_DIR, 'data_out') ...
3c38603390add66e383fbb1117164476cd0f673af5fb855655b3e40f67321a5a
Python
1,099
31
from neuralib.atlas.brainrender.roi import RoiRenderCLI from neuralib.util.utils import ensure_dir from rscvp.atlas.dir import AbstractCCFDir from rscvp.util.cli import RSCRoiClassifierDataFrame from rscvp.util.io import RSCVP_CACHE_DIRECTORY from rscvp.util.util_demo import run_demo class ExampleRun(RoiRenderCLI): ...
41acfa70a8759ab29590f9f4833f76f1128e375b77c7a72980d93e8746a39dda
Python
1,099
65
import os from pathlib import Path class ModelConfig: HIDDEN_CHANNELS = 576 OUT_CHANNELS = 72 NUM_LAYERS = 3 NUM_HEADS = 8 DROPOUT = 0.18 EDGE_ATTR_DIM = 6 USE_GATED_EDGE_ENCODER = True USE_BOTTLENECK_TRANSFORM = True USE_LATE_FUSION = True ...
7411cf7011db153abcf9120e4e5caae8af2c554839dfc79c7b08a6021559979d
Python
1,099
40
import pandas as pd import numpy as np import os from pcafeat import select_pca_features np.random.seed(42) n_samples = 100 n_features = 1000 df_X_train = pd.DataFrame(np.random.randn(n_samples, n_features)) df_X_train.columns = [f'feature_{i}' for i in range(n_features)] target = pd.Series(np.random.randint(0, 2, n...
c4fdfadff41b87568d44208a11db8457a9eb16dd37072bb69599439a9ee793b8
Python
1,099
30
#!/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=['filtering.zip']) tmp_dir = tempfile.Te...
d497eb0b5cd5d53c1c1d225b81dc361a23170036d47e3bdca73f847d5caa0a0b
Python
1,099
27
import torch from torch import nn import torch.nn.functional as F from .grad_rev_layer import GradReverse class ImageDomainDiscriminator(nn.Module): def __init__(self, in_channels: int): super(ImageDomainDiscriminator, self).__init__() self.net = nn.Sequential( nn.Conv2d(in_channels, in...
4f647d7c91501562628cf0fc9f214b9a4309067fa82676532688a90218a91b2d
Python
1,100
36
# Copyright (c) DP Technology. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from functools import lru_cache import numpy as np import torch from tokenizers import BertWordPieceTokenizer from . import BaseWrapperDataset, LRUCacheDataset ...
0f0107ee151183d613b87eac848c47c381e6701d504e6d23969f8159eaa1ff49
Python
1,101
38
import sys import pandas as pd import numpy as np def get_coords(index): coords = pd.DataFrame(index=index) coords['x'] = index.str.split('x').str.get(0).map(float) coords['y'] = index.str.split('x').str.get(1).map(float) return coords def main(): for id in range(9, 12): filename_data_input =...
289256a63c656deb132fb3db9dfdaa0165a905ef7c9409b6a9a5cc12143cfefd
Python
1,103
45
# -*- coding: utf-8 -*- """ Created on Wed Dec 4 13:32:31 2019 @author: Yoshi """ import csv def key_reader(path): # Creates a list for frequencies and intensities frequencies = [] intensities = [] # Creates an empty dict for the key key = {} # Opens key open_key_file = ...
7a85ba0ca51093d8fdb3ef838e8d6cc4d6a6812fcc521d6eb355c22c1e58e7ea
Python
1,103
37
# Generated by Django 3.2.18 on 2023-04-18 09:01 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ("engine", "0067_alter_cloudstorage_credentials_type"), ] operations = [ migrations.AlterModelOptions( name="clientfile", opt...
f00b57ed9bb6496902d49668cf43ac39181da8a03370706bad3a14f2d19093f1
Python
1,103
39
import os from datetime import datetime import logging from iso_analysis.io import load_eeg_data from iso_analysis.analysis import run_iso_analysis from iso_analysis.utils.logging import setup_logging def main(): base_data_path = './data' montage_paths = { '32': 'eeg_ch_coords/coordinates32.xml', ...
36faaa0d1976628ce5cf5438ab38ec3862894661538daac3cf9e0e4d8bf5588a
Python
1,104
53
"""Get inferred parameters. """ from sys import argv if len(argv) != 3: print("Please pass the number of modes and run id, e.g. python 3_get_inf_params.py 6 1") exit() n_modes = int(argv[1]) run = int(argv[2]) #%% Import packages print("Importing packages") import os import pickle import numpy as np from o...
6a9ed000f08a40962edfadc36746804e410e831ddcb41fc736511546cbfb1b01
Python
1,104
33
#! /usr/bin/env python3 class LossTracker: def __init__(self, loss_names): if "total_loss" not in loss_names: loss_names.append("total_loss") self.losses = {key: 0 for key in loss_names} self.loss_weights = {key: 1 for key in loss_names} def weight_the_losses(self, exclude...
7adb8f783c7113e27657f1749c9d3fa7ce7dce9754749698f8b934cd700898aa
Python
1,105
34
"""Deprecated compatibility shim for Anthropic model loading. Construction now lives in ``chemgraph.models.endpoints.anthropic_direct`` behind the Anthropic-native protocol builder. Prefer ``chemgraph.models.loader.load_chat_model``. """ from __future__ import annotations import warnings from langchain_anthropic im...
d11ca8be187500a0b30463dfc237732b3a17fb936c034bc82ae9a15b97de6700
Python
1,105
39
# Generated by Django 2.1.3 on 2018-12-05 13:24 import django.db.models.deletion from django.db import migrations, models class Migration(migrations.Migration): initial = True dependencies = [ ("engine", "0014_job_max_shape_id"), ] replaces = [("git", "0001_initial")] operations = [ ...
f6518c28adc6e78328c4a2157400f0d0aba71c5c3bb8ad79a5c5d399c3192298
Python
1,105
40
# Copyright (C) 2025 Intel Corporation # Copyright (C) CVAT.ai Corporation # # SPDX-License-Identifier: MIT import io from collections.abc import Callable from contextlib import closing from typing import ClassVar import attrs from PIL import Image from shared.tasks.base import TaskSpecBase from shared.tasks.enums i...
651644199aae928ece751bd3e0b62d6d2ad6af084bdb17aa8766101e95e295d1
Python
1,106
30
import numpy as np from brainscore_core import Metric from brainscore_vision.metrics import Score ''' This metric takes in two floats and gives a score between 0 and 1 based on how far apart the numbers are, using a sigmoid function. ''' class ValueDelta(Metric): def __init__(self, scale: float = 1.00): ...
a61332510e2baf352c7171573af1c738784e43b9ee18ce0b652055c97fba608c
Python
1,106
32
import seisbench from .base import WaveformBenchmarkDataset class Iquique(WaveformBenchmarkDataset): """ Iquique Benchmark Dataset of local events used for training in Woollam (2019) study (see citation). Splits are set using standard random sampling of :py:class:`seisbench.data.base.BenchmarkDatase...
687f5910858f072c7f274d3b667e5326373690dd0eb056488969de56992e8456
Python
1,107
43
#!/usr/bin/env python """ Mask out potential CpG sites from a maf. Restricted or inclusive definition of CpG sites can be used. The total fraction masked is printed to stderr. usage: %prog < input > output -m, --mask=N: Character to use as mask ('?' is default) -r, --restricted: Use restricted definition of C...
95567043e05ea187b86364286906176f4d879fb5bc059f5aa3b87007f8819460
Python
1,107
32
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import os import tempfile import numpy as np 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='surface_vtk_fib.zip...
27cce82131d7fd4270e525049f93632a3e22407f8258954cbaf4ec81ab95e305
Python
1,108
31
#!/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=['commit_amico.zip']) tmp_dir = tempfile...
e5344ace459e98d99813874384512501f5941afa94305af3725e21aeadce96a1
Python
1,108
42
"""Example script for testing if evoked responses are statistically significant. """ import numpy as np from osl_dynamics.analysis import statistics from osl_dynamics.utils import plotting # Generate some random data n_samples = 64 n_modes = 4 n_subjects = 24 epochs = np.random.randn(n_subjects, n_samples, n_modes...
b91256a361a12e8f66ae0f5f2f64c5d301d352f9a438587723ae942cf30a23b8
Python
1,110
45
from tensorflow.keras import mixed_precision mixed_precision.set_global_policy("mixed_float16") from tensorflow.keras.optimizers import Adam from tensorflow.keras.optimizers.schedules import PolynomialDecay import json import sys sys.path.append('..') from model_architecture import Model from input_pipeline.tf_datas...
18f21f80ec650e874e2595b886cf7870d20a6535e13b54fc5b967aadd241c058
Python
1,111
43
from scipy import stats import numpy as np from .base import Distribution class Normal(Distribution): """Normal prior. Parameters ---------- mean : scalar or ndarray Mean of distribution sd : scalar or ndarray Standard deviation of distribution Examples -------- Defi...
e04be4c9dc42f5fd9ac17b0c685e72687a08758b70d7ebdffa2217b577529f86
Python
1,111
43
"""test_locf.py""" import numpy as np import impyute as impy from impyute.ops.testing import return_na_check from impyute.ops import error SHAPE = (5, 5) def test_locf_(test_data): data = test_data(SHAPE) imputed = impy.locf(data) return_na_check(imputed) def test_na_at_i_start(test_data): data = t...
b0f03b1b2e665407fe9536c5d842c54f38826f24d4d7aa6295115d6f3dbd837a
Python
1,112
27
from pathlib import Path from typing import Optional, Tuple from aicsimageio.readers.czi_reader import CziReader from PIL import Image from tqdm import tqdm from brainways.utils.image import resize_image, slice_to_uint8 def convert_czi_to_jpg( input_path: Path, output_path: Path, size: Optional[Tuple[int, int]]...
b912d75163a4dfd14257bb53cd4a5c336a1750061780e3ec6439d7d5cf6ac0a1
Python
1,112
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=['stats.zip']) tmp_dir = tempfile.Tempor...
dbafdaaf67a4f33f8a6d991cc071ddefd3975e77ef37346067dc152e9b8ab90d
Python
1,112
55
#!/usr/bin/env python3 import arbor as A from mpi4py import MPI import sys T = 1000 dt = 0.025 class recipe(A.recipe): def __init__(self, num=1): A.recipe.__init__(self) self.num = num self.weight = 20.0 self.delay = 0.1 def num_cells(self): return self.num def ...
0b4fdf413646f3514bc139fc6417c889e9ecdd1e1e960f86aa7304c4d0c52eea
Python
1,113
42
#!/usr/bin/env python # -*- coding: utf-8 -*- import jieba import threading def inittokenizer(tokenizer, group): print('===> Thread %s:%s started' % (group, threading.current_thread().ident)) tokenizer.initialize() print('<=== Thread %s:%s finished' % (group, threading.current_thread().ident)) tokrs1 = [jieba.Tok...
0c3303b44f572589931309d06a879e44c0e3bf9e75a0c581c63504b4ded34d2f
Python
1,113
37
"""Every module in the package must be importable. Catches typo'd import paths and missing dependencies before they reach a user. """ import importlib import pkgutil import sys import pytest import histo_miner MODULES = [m.name for m in pkgutil.walk_packages(histo_miner.__path__, "histo_miner.")] # Packages declar...
5a4837dfd01c6eeeacd31a3f7951037d132a58d301b4a4d51d05a1cca5b66052
Python
1,113
31
#!/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=['bundles.zip']) tmp_dir = tempfile.Temp...
82b8d544c3cae4b4c178e3b446915f33ae2911025006705c58ef55dc070980ea
Python
1,113
45
from __future__ import division from __future__ import print_function import numpy as np import scipy.sparse as sp import torch def normalize(mx): # """Row-normalize sparse matrix""" rowsum = np.array(mx.sum(1)) r_inv = np.power(rowsum, -1).flatten() r_inv[np.isinf(r_inv)] = 0. r_mat_inv = sp.di...
0a6878d50bb7ceffc73b4bce49702e220a7b136622090f29cba8fd2b3d4897a6
Python
1,114
29
import click from brainways.scripts.batch_create_thumbnails import batch_create_thumbnails from brainways.scripts.create_excel import create_excel from brainways.scripts.create_reg_model_data import create_reg_model_data from brainways.scripts.import_cell_detections_keren import import_cell_detections_keren from brain...
5376ee8a9f91e4ebe29b2308d59adad5a9c5f026e41eb4b86a97b93e461895be
Python
1,114
23
import os from nipype.interfaces.base import (CommandLineInputSpec, CommandLine, traits, TraitedSpec, BaseInterface, BaseInterfaceInputSpec, File) from traits.api import Directory, Str, List, Bool, Enum, Int, Float, TraitError, Either #################### # Make BIANCA mask # #################### class MakeBIANCAMaskI...
593f126a819237dbcec4c7ab2b1ec66d26d98c93f159e8924cd389a2f8954c09
Python
1,114
33
# src/models/regression_model.py """ Multi-output regression MLP for 8 surgical doses (0–10 mm). """ from __future__ import annotations import torch, torch.nn as nn from src.config import C class RegressionModel(nn.Module): def __init__(self): super().__init__() in_dim = getattr(C, "INPUT_DIM"...
5b96206b419b9ba799920efcf3f34a7a216ad60c961bfd533425ee1e17836d16
Python
1,114
39
import string import sys import os import glob import re import csv, logging PROTEOMIC_DATA_FILE = '../data/hsa_nagaraj/hsa_actin_tubulin_abundance.csv' KO_TO_UNIPROT_FILE = '../data/KO_gene_hierarchy/KO_gene_hierarchy_organism_mapping/hsa_mapping.csv' OUTPUT_PATH = '../res/hsa_nagaraj/' if not os.path.exists(OUTPUT_P...
6cd306967aeeb1eb1219692f42246b4b5939b7784d41732ccfc2a6f318fddb25
Python
1,115
54
import os # Model MODEL_NAME = 'unetr' # wandb logging WANDB_LOG = False # Classes ORGANS = ['glomeruli'] NUM_CLASSES = len(ORGANS) + 1 # +1 for background # CZI Path # PROJECT_PATH = '/hdd/yang/kidney_seg/kidney_unetr' # DATA_PATH = '/hdd/yang/data/kidney_seg' # CS Cluster # PROJECT_PATH = '/home/zhouyang/kidne...
91d158ff485807ebebcbd9c5139b5b2f158bf12291f2d2f79b2b2b881133f8ea
Python
1,115
31
import numpy as np import torch from sklearn.metrics import mean_absolute_error, mean_squared_error, r2_score @torch.no_grad() def evaluate(model, X, y_scaled, device, radius_max): model.eval() preds = model(torch.from_numpy(X).to(device)).cpu().numpy() y_pred = np.zeros_like(preds) y_pred[:...
9602f62346397fced7e5831d6f6d805db51a512d6eecd4ed38a519911aab3e55
Python
1,116
69
from .application import ApplicationBackend from .widgets import ( CheckBox, ComboBox, Container, DateEdit, DateTimeEdit, FloatRangeSlider, FloatSlider, FloatSpinBox, Image, Label, LineEdit, LiteralEvalLineEdit, MainWindow, Menu, MenuBar, Password, Pro...
9b1e1d4685439a45ab0252670fad04422f2377f0dd2b603b8fb3ae9ad56d633a
Python
1,116
52
import os import os.path import shutil def double_quote(v): return '"{}"'.format(v) def recreate_dirs(dir_paths): for dir_path in dir_paths: if os.path.isdir(dir_path): shutil.rmtree(dir_path) os.makedirs(dir_path) def gene_id_str(n): # pad n with '0' on the left to make i...
4d6a978532cfbdfea003ab028a4284365b668ab4e6ac1a00c128ce40db8d3181
Python
1,118
39
""" Create a 3D mesh with conforming bifurcation """ import SVMTK as svm from pathlib import Path if __name__ == "__main__": print("Start ",__file__) surf = svm.Surface() outdir = Path("results") outdir.mkdir(exist_ok=True) # Cube corner coordinates and edge length. x0,y0,z0,x1,y1,z1, edge_le...
703d2aa81daccaf246973c147df8d499598eb7fe4ed33ef46b28aadfa3f92df8
Python
1,118
30
import os def split_file(): """ To split up a donor file into chunks to test effect of sample size on training """ current_dir = os.path.dirname(__file__) for fold in range(10): original_file_path = os.path.join(current_dir,f'gtex/cv_folds/person_ids-train-fold{fold}.txt') # Read a...
9519d857e6971835d1b101a90bf3ea70a0d9355052e65105c5d512ea1ba3052f
Python
1,118
42
""" Export slice meshes as surface in 3D """ import SVMTK as svm from pathlib import Path if __name__ == "__main__": print("Start ",__file__) outdir = Path("results") outdir.mkdir(exist_ok=True) # Load Surface surf = svm.Surface("../Data/lh-pial.stl") ### Create and export slice mesh 1 #...
b336e948a99da3a2c111327aa9e1d31f6e1744305890bd854efa8812ed46bcce
Python
1,118
28
import os from typing import Tuple from dotenv import load_dotenv from util.io import MissingEnvironmentVariables def get_environment_variables() -> Tuple[str, str, str, str]: """ Gets the environment variables needed for logging into the XNAT-Server. Please set environment variables in a .env file in the...
f9d5a7520bc2b30bd78fbd00cba0543c1e24018e359a6272aad028e970d3b0dd
Python
1,118
39
""" Create 3D mesh with two conforming edge helixes inside """ import SVMTK as svm import numpy as np from pathlib import Path if __name__ == "__main__": print("Start ",__file__) surf = svm.Surface(); outdir = Path("results") outdir.mkdir(exist_ok=True) # Lower center coordinates x0,y0,z0 =...
259d53f8eb1d04ff125a14d9d0dc05cebc53df4f8671a33c5e47e4c743893b9d
Python
1,119
32
import pytest from chemgraph.agent.llm_agent import ChemGraph from unittest.mock import Mock, patch from langchain_core.messages import HumanMessage, AIMessage @pytest.fixture def mock_llm(): return Mock() def test_chemgraph_initialization(): with patch("chemgraph.agent.llm_agent.load_openai_model") as mock...
6a76c100bc949fe8a4a004c54e7b8e25d58ba005745773dde2e54f39a4534f55
Python
1,119
31
#!/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='surface_vtk_fib.zip') tmp_dir = tempfil...