sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
882dd52cf859d070f594f676906b77241e64576357d39e91bd5d87148aac025a
Python
3,121
85
import glob import os.path as osp import re from ..utils.data import BaseImageDataset def process_dir(dir_path, relabel=False): img_paths = glob.glob(osp.join(dir_path, "*.jpg")) pattern = re.compile(r"([-\d]+)_c(\d)") # get all identities pid_container = set() for img_path in img_paths: ...
a08cd82723f8d265859c572f1407b75979fba719be4bdbf0ceb7763b8787b823
Python
3,121
82
import numpy as np import torch import torch.utils.data as data_utils class DatasetLoader: def __init__(self, all_dataset, batch_size): self.all_dataset = all_dataset self.batch_size = batch_size @staticmethod def worker_init_fn(worker_id): np.random.seed(np.random.get_state()[1][...
b4b56ff7d367402b88214d67c60546187b82d16a5dbe4288daac6713d3d06c3f
Python
3,121
105
import os import os.path as osp import numpy as np import torch from torch.utils.data import Dataset import cv2 import matplotlib.pyplot as plt import albumentations as A from PIL import Image from albumentations.pytorch import ToTensorV2 def get_training_transform(): return A.Compose( [ A.Resize(25...
e386ce522b277938f064f87294a9fdfcdee5d063acd790d465943cd25c0c0845
Python
3,121
75
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved from torch import nn from torchvision.ops import roi_align # NOTE: torchvision's RoIAlign has a different default aligned=False class ROIAlign(nn.Module): def __init__(self, output_size, spatial_scale, sampling_ratio, aligned=True): ...
1294cd258cbce4255968bb657ae33e1b5482035a30382def7445898c542dd91d
Python
3,123
100
# 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 # # Unless required by app...
69e55750e4f4f850c80f2282c1c3a6f98369d732889549eacb9896a441cba914
Python
3,123
91
# Copyright (C) 2021-2022 Intel Corporation # Copyright (C) CVAT.ai Corporation # # SPDX-License-Identifier: MIT from drf_spectacular.utils import OpenApiParameter from rest_framework.filters import BaseFilterBackend ORG_SLUG_PARAM_DESCRIPTION = """\ Organization unique slug. If omitted, results from all organization...
7c5403063456538348556e82fdf106f0d7938e524ff5d750fd73ff5f6a75ffc3
Python
3,123
64
# -*- coding: utf-8 -*- import pandas, numpy, math, multiprocessing, os from scipy.stats import chisquare from scipy.spatial import distance from functools import partial import matplotlib.pyplot as plt from matplotlib.ticker import EngFormatter, FormatStrFormatter def find_average_rho(dots, dot, dc,...
9d69354b39207693b4e26dcc3a746986025691e488e8275f790843184f5a3526
Python
3,123
105
# -*- coding: utf-8 -*- """ Gradient nonlinearity correction of time series This scripts calls the HCP toolbox to correct for gradient nonlinearities in the input time series. The corrected time series gets the suffix _gnlcorr. The script needs an installation of fsl. Dependencies: - gradunwarp: https://github.com/Wa...
6ebf3fe8676acef3bca73363afbcd43c940e443fca62bbb31b430fd3677c6d34
Python
3,124
101
from psychopy import prefs # noqa prefs.hardware['audioLib'] = ['PTB', 'sounddevice', 'pyo', 'pygame'] # noqa from psychopy import visual, core, event, sound, __version__, monitors import os from psychopy.hardware import keyboard import random # stop the script by pressing escape def prepare_audio_stim(categories=...
4af1a2711dfddfaf939cd355a2e3266935fa352a910393c253fe4c65ab83d1a5
Python
3,125
94
import sys import getopt import json import scipy.ndimage as nd from skimage import io as skio import numpy as np from PIL import ImageFile from PIL import Image ImageFile.LOAD_TRUNCATED_IMAGES = True Image.MAX_IMAGE_PIXELS = None # usage def affine_ssdna_usage(): print(""" Usage : affine_ssdna.py -i <input.tif/...
6034fd1ab5f21982ec9cb22f000da4def8c250c44653d9ed180dc3185e86b2cc
Python
3,125
98
import spams import numpy as np import cv2 import time class vahadane(object): def __init__(self, STAIN_NUM=2, THRESH=0.9, LAMBDA1=0.01, LAMBDA2=0.01, ITER=100, fast_mode=0, getH_mode=0): self.STAIN_NUM = STAIN_NUM self.THRESH = THRESH self.LAMBDA1 = LAMBDA1 self.LAMBDA2 = LAM...
16096899c8dc821609a5004f6516f99e8c8660e759b3887caca87daaf74b7d80
Python
3,126
114
"""Utility functions for data loading operations.""" from typing import Any import numpy as np from mcmlnet.utils.tensor import ( TensorType, array_conversion_decorator, ) def subsample_data( data: TensorType, subsample_size: int, random_seed: int = 42 ) -> TensorType: """Subsample data to a specif...
26740876ff1b6649c2fe1d12110a45db3b0c2678d8e9de2f9f7d9a770d2f9924
Python
3,126
81
from pathlib import Path from brainscore_core.supported_data_standards.brainio.stimuli import StimulusSet from brainscore_core.supported_data_standards.brainio.packaging import package_stimulus_set stimuli = [] image_paths = {} stimuli_directory = '../datasets/low-pass/dnn/session-1' ''' Dataset Meta Info (from http...
0ceef905f345086a73aad3fb515263a1887dfc5e3cf13667f7b8e70813a85245
Python
3,127
95
import os from importlib import import_module from pathlib import Path cell_graph_config = { "cell_f_list": [ 'fourier', 10, False, [ 'area', 'r_equiv', 'r_maj', 'r_min', 'angel', 'ecc', 'maj_x', ...
7acabdf6575f0b3bda69fa647150af4dafb1039ea2d5fe44d823ebfaa5becf52
Python
3,127
82
from pathlib import Path from brainscore_core.supported_data_standards.brainio.stimuli import StimulusSet from brainscore_core.supported_data_standards.brainio.packaging import package_stimulus_set stimuli = [] image_paths = {} stimuli_directory = '../datasets/rotation/dnn/session-1' ''' Dataset Meta Info (from http...
8b3246dcddc5cbd05e9edece4d92d623244d24adcafdcaa6c34f50eb215b7bfc
Python
3,127
86
import json import pandas as pd import pytest from metaprivBIDS.cli import main @pytest.fixture def input_file(tmp_path): path = tmp_path / "input.csv" pd.DataFrame( { "ID": [101, 202, 303, 404, 505], "age": [25.5, 35.5, 45.5, 25.5, 35.5], "city": ["A", "B", "A", ...
b314f0d5d759460243b927b7ed74605cef238ead93bd2cd6e32e69ab52c5525a
Python
3,127
82
############################################################################# # Copyright (C) 2020-2026 MEmilio # # Authors: Daniel Abele # # Contact: Martin J. Kuehn <Martin.Kuehn@DLR.de> # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the Licen...
78000be1bceceae0355e6d7de7b55b9d8f4a4f87bb08e827cc4dc156cc75be90
Python
3,128
109
# %% ### import modules from pathlib import Path import pandas as pd # %% read results table results_dir = Path(__file__).resolve().parents[1] / "results" df = pd.read_excel(results_dir / "cs_b_results.xlsx") # combine Estimate and Std. Error to Estimate (Std. Error) # round to 5 decimal places df["Estimate"] = df["...
e795ca8dceaeaf6d9127d3b2647d9d3582414410fbcaad5c5b23d53e476c284f
Python
3,128
91
from dataclasses import dataclass from typing import TYPE_CHECKING import torch from torch import nn from eir.models.layers.mlp_layers import MLPResidualBlock, ResidualMLPConfig from eir.models.models_utils import create_multi_task_blocks_with_first_adaptor_block if TYPE_CHECKING: from eir.setup.output_setup_mod...
42880cd2af4936ea73f6934597487849aa917d162ee8d0368d42d8b84fbe6a75
Python
3,130
82
from pathlib import Path from brainscore_core.supported_data_standards.brainio.stimuli import StimulusSet from brainscore_core.supported_data_standards.brainio.packaging import package_stimulus_set stimuli = [] image_paths = {} stimuli_directory = '../datasets/high-pass/dnn/session-1' ''' Dataset Meta Info (from htt...
e9de113d9d5f6607fb378bc551d498e02696351a1ec0e90e781cb35499481003
Python
3,130
108
import os import tempfile from typing import List import ngs_tools as ngs from ..config import ( PLATFORM, TECHNOLOGIES_MAPPING, UnsupportedOSError, ) def run_executable(command: List[str], quiet: bool = False, *args, **kwargs): """Dry version of `utils.run_executable`. """ command = [str(c)...
0137029c0d8673ee8e6d20c61229d4bbc8a2ac2ebc8e001830d2dd02a250ae17
Python
3,131
74
#!/usr/bin/env python import SimpleITK as sitk import numpy as np import os import argparse def segment_air(input_file: str, output_mask_file: str, air_max_threshold: float = -990, air_min_threshold: float = -1010): """ Segments air from a NIfTI image using a simple thresholding method. Parameters: ...
16ad3917c2558e0894739a9c8ce5229bbda6c9a1671877d4e3ef852574c9e72e
Python
3,131
89
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: # # STATEMENT OF CHANGES: This file is derived from sources licensed under the Apache-2.0 terms, # and this file has been changed. # The original file this work derives from is found at: # https://github.co...
4189d00213c3acc403ca7e613ad8923e77f1316f0de9dc2ac60d307fca03bd68
Python
3,131
71
import os import nibabel as nib from dipy.core.gradients import gradient_table from dipy.data import fetch_hbn import dipy.reconst.dti as dti import dipy.reconst.fwdti as fwdti import numpy as np from nipype.interfaces.base import BaseInterface, BaseInterfaceInputSpec, TraitedSpec, File, Directory, traits, CommandLineI...
748166fd025ba770128046b98cd57c1062160d2bc988a3e6ef460147e71f81fd
Python
3,131
95
# Copyright (C) CVAT.ai Corporation # # SPDX-License-Identifier: MIT """Prepare the Moto S3 server for cloud storage tests. Create the fixture buckets, upload sample files and manifests, enable anonymous access to the public bucket, and create an empty bucket for backing storage. Connection settings and credentials c...
7efe52375b5ad29dc5986caebe5c5f54ebbd5499c3e03d910bf2364b9d40ee10
Python
3,132
58
# -*- coding: utf-8 -*- """ Created on Fri Oct 21 12:34:47 2022 @author: tianj """ import numpy as np import torch import os import generator import dataset from dataset import DECAMDataSet from generator import Generator patch_size=3 for subj in ['25Q']: for epoch_label in [40]: for s ...
39414ee92ef539ec811e94fc8ef623989c871f3ff0ae54840e26a4de0c7f0651
Python
3,133
82
from pathlib import Path from brainscore_core.supported_data_standards.brainio.stimuli import StimulusSet from brainscore_core.supported_data_standards.brainio.packaging import package_stimulus_set stimuli = [] image_paths = {} stimuli_directory = '../datasets/eidolonI/dnn/session-1' ''' Dataset Meta Info (from http...
bec329f9241528ce028da44006db847f642659e2f5585fa16fd1288c1a8a233f
Python
3,133
95
# Generated by Django 4.2.14 on 2024-07-22 07:27 import django.db.models.deletion from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ("engine", "0081_job_assignee_updated_date_and_more"), ] operations = [ migrations.AlterField( m...
fbe9e809e118e2927532b76538d54d68ef6403c206b4245e71212e3f3bc5603e
Python
3,133
100
# -*- coding: utf-8 -*- from dipy.utils.deprecator import cmp_pkg_version, ExpiredDeprecationError from functools import wraps from packaging.version import parse import warnings from scilpy import version class ScilpyExpiredDeprecation(ExpiredDeprecationError): pass DEFAULT_SEPARATOR = "=" DEFAULT_DEPRECATIO...
84ba6bf6ce1c5d73113070b1738489e8a57f113b7405db09ce42cc1328cfe2b9
Python
3,134
82
from pathlib import Path from brainscore_core.supported_data_standards.brainio.stimuli import StimulusSet from brainscore_core.supported_data_standards.brainio.packaging import package_stimulus_set stimuli = [] image_paths = {} stimuli_directory = '../datasets/contrast/dnn/session-1' ''' Dataset Meta Info (from http...
10ffaa44bfc609c3945dc31fcf991892dce7c659ba5a120e2b948e4311fb1f85
Python
3,135
69
from qtpy.QtCore import Qt from qtpy.QtWidgets import QWidget, QHBoxLayout, QSpinBox,QLabel,QPushButton,QDoubleSpinBox import numpy as np class AnchorRow(QWidget): def __init__(self, regHelper): super().__init__() self.regHelper = regHelper # create horizontal layout self.anc_hbox =...
316881f277125ff5ac7f93cde0f2fb10e2bb54c3013ffda25dda253c228af44f
Python
3,135
101
""" Run XANES workflows via the ChemGraph agent using MCP HTTP transport. Connects to an already-running XANES MCP server via HTTP. The LLM agent receives the XANES MCP tools and uses them to fulfill the natural language prompt. Prerequisites: - XANES MCP server running (via start_mcp_server.sub or manually) - S...
8fd223a983503940c6238e53e5098ed9cd46193e7354b5f2a778410d50e9872a
Python
3,135
82
from pathlib import Path from brainscore_core.supported_data_standards.brainio.stimuli import StimulusSet from brainscore_core.supported_data_standards.brainio.packaging import package_stimulus_set stimuli = [] image_paths = {} stimuli_directory = '../datasets/eidolonII/dnn/session-1' ''' Dataset Meta Info (from htt...
96517916d9d6a1a02d7b1ea9a186337a2c84e87a9162b73b7286286bb8ccfb05
Python
3,136
69
from PyQt5.QtCore import Qt from PyQt5.QtWidgets import QWidget, QHBoxLayout, QSpinBox,QLabel,QPushButton,QDoubleSpinBox import numpy as np class AnchorRow(QWidget): def __init__(self, regHelper): super().__init__() self.regHelper = regHelper # create horizontal layout self.anc_hbox...
5b8d3c7ab6ce8d6aebbd5c1740b886c77c91f069694e3dd8a4f8ae431a7d3420
Python
3,137
71
import numpy as np import numpy.testing as npt import pytest #import torch from utilities.data_simulation.GenerateData import GenerateData #run using python -m pytest from the root folder test_monoexponential_data = [ pytest.param(0, np.linspace(0, 1000, 11), id='0'), pytest.param(0.1, np.linspace(0, 1000, 1...
7bef2274f2bc87926c5cd44fad8d4571b9b17f9ac4299c37c3d91fc0093f5455
Python
3,137
82
from pathlib import Path from brainscore_core.supported_data_standards.brainio.stimuli import StimulusSet from brainscore_core.supported_data_standards.brainio.packaging import package_stimulus_set stimuli = [] image_paths = {} stimuli_directory = '../datasets/eidolonIII/dnn/session-1' ''' Dataset Meta Info (from ht...
b1c2e6a4f687ecf17b623ece5df48d237820d172c5574fc64efec6db3d55941d
Python
3,138
91
import os import numpy as np available_gpus = ['0,6', '6,0'] parallel_starts = 8 # args dict args_dict = {'device': 7, # gpu 'log_steps': 1, 'num_layers': 3, 'hidden_channels': 256, 'dropout': 0.0, 'batch_size': 64 * 1024, 'lr': 1.e-03, 'epo...
07772027f903b555e160cf76a9c50a7f6494bba5287171c0f82c5c0800cc5820
Python
3,139
83
"""Tests for the `morphometrics status` command (derived from work_dir artifacts).""" from click.testing import CliRunner from surface_morphometrics.status import status_cli, _refine_status def _touch(path): open(path, "w").close() def _csv(path, columns): with open(path, "w") as handle: handle.wri...
7e55e981ef7426613ebeb9f34e18c041dcaf04d58e00c4083bd5fdaa8e602ca9
Python
3,140
109
import datetime as dt import json import os import sys from typing import Dict, List, Optional, Union from . import __version__ from .config import ( get_bustools_binary_path, get_kallisto_binary_path, is_dry, ) from .dry import dummy_function from .dry import dryable class Stats: """Class used to co...
1c216f2173afd9ee319e62850fae1876c07975e3b464da247c45138d31e05d0e
Python
3,141
67
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license from __future__ import annotations from pathlib import Path from ultralytics import SAM, YOLO def auto_annotate( data: str | Path, det_model: str = "yolo26x.pt", sam_model: str = "sam_b.pt", device: str = "", conf: float = 0.25...
3ddff1e0057f73fd2865f82cbf48f83f8711f92d319e516bd013567d9cde01d1
Python
3,143
82
from pathlib import Path from brainscore_core.supported_data_standards.brainio.stimuli import StimulusSet from brainscore_core.supported_data_standards.brainio.packaging import package_stimulus_set stimuli = [] image_paths = {} stimuli_directory = '../datasets/phase-scrambling/dnn/session-1' ''' Dataset Meta Info (f...
d8b1da72fa65aa703978b47fbc1c59f5c1f865210bb1cb2ac43827d6da3f52d6
Python
3,143
82
from pathlib import Path from brainscore_core.supported_data_standards.brainio.stimuli import StimulusSet from brainscore_core.supported_data_standards.brainio.packaging import package_stimulus_set stimuli = [] image_paths = {} stimuli_directory = '../datasets/uniform-noise/dnn/session-1' ''' Dataset Meta Info (from...
cb29106110502610ee895b7ca78d96bd0698f7762ddaabf1b2133232fa0a5887
Python
3,144
86
""" EC_GridSearch @ 2022 Knowblesse Find the best hyperparameter for EV """ import numpy as np from numpy.random import default_rng from pathlib import Path import sklearn from sklearn.metrics import confusion_matrix from sklearn.svm import SVC from sklearn.model_selection import LeaveOneOut from sklearn.metrics import...
3ca1139aae5627584c459859b61a0e55767a4079f679eb3d08575e7e5341de59
Python
3,146
93
# -*- coding: utf-8 -*- """ Created on Wed Jun 4 17:55:18 2025 @author: giga """ import pandas as pd import numpy as np import os from pathlib import Path # Define the base directory and model names base_dir = r"D:\1Grok\Output" models = ["ANFIS", "ANN", "Transformer", "SVR", "LightGBM", "XGBoost", "E...
579d2307c618ea2cb14c755df7b8487c7c69f2b8393558f52904546255d9f34e
Python
3,146
112
import arbor as A from arbor import units as U import numpy as np import subprocess as sp from pathlib import Path # Spherical geometry from the paper # - V = 4/3 pi r^3 = pi r^3 # - A = 4 pi r^2 # now compute the equivalent square # cylinder mantle: # - A = 2 pi l^2 VOLUME = 2160 RADIUS = (0.75 * VOLUME / np.pi) **...
bb96ea10e8a1b8ec19428cc5e3a2891df7f58e3c4b546cc62365d01fa13e0f94
Python
3,146
95
import click import os import numpy as np from torch.utils.data import DataLoader import torch from pli_cyto.models.dft_style import DFTStyleLitModule from pli_cyto.models.dft_wgan import DFTGanLitModule from pli_cyto.utils.files import get_files, save_section, create_cyto from pli_cyto.datamodules.components.sectio...
03e564ff713039030bb66dabec5dc225c09233d571f83e8ebe512795199c91b6
Python
3,148
101
import hashlib from pathlib import Path import subprocess as sp import shutil try: from rich import print except ImportError: # pragma: no cover - optional dependency for nicer CLI output pass def calcHash(filepath): return hashlib.md5( open(filepath, 'rb').read() ).hexdigest() def shipResu...
62df1cf773dfaf596f7664a7f676e3ca7abdf50f4370412fbc38bdd6932df5e2
Python
3,148
76
from torch.utils.data import DataLoader from geoseg.losses import * from geoseg.datasets.cvc_clinic import CVC_Dataset from geoseg.models.deepunet.DeepUnet import Model from catalyst.contrib.nn import Lookahead from catalyst import utils CLASSES=('background', 'foreground') # training hparam max_epoch = 100 ignore_i...
b462c7fd08ce91a38c3286f5b6b6ddf61c43f295de58132c498201a1be4ad235
Python
3,148
82
from pathlib import Path from brainscore_core.supported_data_standards.brainio.stimuli import StimulusSet from brainscore_core.supported_data_standards.brainio.packaging import package_stimulus_set stimuli = [] image_paths = {} stimuli_directory = '../datasets/power-equalisation/dnn/session-1' ''' Dataset Meta Info ...
d8ace0ba95c8b750ae67f2a12e0074fc99460b16b394062d192a2957218a3cc6
Python
3,148
101
# Copyright (C) CVAT.ai Corporation # # SPDX-License-Identifier: MIT import io import zipfile from pathlib import Path from typing import TypeAlias import pytest from cvat_sdk.core.proxies.jobs import Job from cvat_sdk.core.proxies.projects import Project from cvat_sdk.core.proxies.tasks import Task from cvat_sdk.core...
72dbbdb313e9175de765098897be87203accfa9552898a702e002f964ee44c6d
Python
3,149
89
'''Test the standard calibration class''' import unittest from ogo.calibration.standard_calibration import StandardCalibration import os class TestStandardCalibration(unittest.TestCase): '''Test the standard calibration class''' def test_can_instantiate(self): '''As an inherited class from an abstra...
7daec36ae796740cf1f50e7f17b5281a1db961320fd1f2b2aba579a51cf012cf
Python
3,151
77
from generative.networks.nets import VQVAE import torch.nn as nn import torch from kornia.losses import SSIMLoss import os from PIL import Image import numpy as np class LdmVQVAE(VQVAE): def __init__(self, log_image_epoch, log_path, ckpt_path=None, *args, **kwargs): super().__init__(num_channels=(128, 256)...
2b1cb96633f5f9762bb3871e081895fb4ac358a8cec8b05fb7b5644b30cbf5a4
Python
3,153
80
# -*- coding: utf-8 -*- """ Created on Mon Jun 5 14:27:32 2023 @author: DODO """ import numpy as np import sys import os import datetime import matplotlib.pyplot as plt import scipy.interpolate as itp import warnings warnings.filterwarnings('ignore') def b_constraint_fromabaqus(TASK_NAME = "202310...
46531db0410ddecbc548867fb96769a266278efaa8423a1af94ee0c25006b130
Python
3,153
107
# coding=utf-8 """ Module to warp a image with given ddf. A CLI tool is provided. """ import argparse import os import nibabel as nib import numpy as np import tensorflow as tf from deepreg import log from deepreg.dataset.loader.nifti_loader import load_nifti_file from deepreg.model.layer import Warping logger = l...
e26a8baaf6276d6e4f3cf2ee1875c46f1ec08dbee8d68c5cab1dae755e3bc8ff
Python
3,154
78
from pathlib import Path from typing import Union, Optional import nibabel as nib from auxiliary.io import read_image, write_image from brainles_preprocessing.defacing.defacer import Defacer from brainles_preprocessing.defacing.quickshear.nipy_quickshear import run_quickshear from brainles_preprocessing.constants imp...
50b61723eff6b39de09cf1ece22bc9a728ba970240f90e5c7d84e1453924c070
Python
3,155
77
'''Script to fit RGB heatmap images to a source color palette.''' import click import numpy as np from PIL import Image from zennit.image import CMAPS, palette def gale_shapley(dist): '''Find a stable matching given a distance matrix.''' preference = np.argsort(dist, axis=1) proposed = np.zeros(dist.shap...
530e7249d549c92d25bbe4f305255949c40a6dae42ee2bd253ff7e5295cd7539
Python
3,155
98
# 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. import numpy as np from functools import lru_cache from unicore.data import BaseWrapperDataset, data_utils from copy import deepcopy from tqdm import tqdm class C...
934f4d35d7c09b6fd06e06f9cb88b8e8b5ad00b11a83970ad748bbe2723cae9b
Python
3,155
104
from torch.utils.data import Dataset from utilFunc import readCSV import argParser as ARG from torchvision.transforms import v2 from PIL import Image import torchvision.transforms.functional import torch TEST = "test" TRAIN = "train" VALIDATE = "validate" POSSIBLE_SPLITS = [ TEST, TRAIN, VALIDATE, ] if A...
fc8811e53c4d7a0f6201102f36e8d1cc49deb1119f00d45b0cae72f1b92c2b32
Python
3,155
96
"""Tiny TCP relay used by the dashboard launcher. Listens on a UAN-visible port and forwards every accepted connection to a loopback service on the same UAN host. The dashboard launcher pairs this with a reverse SSH tunnel (Mac argo-shim -> UAN loopback), so compute nodes can curl http://<uan>:<port>/argoapi/v1 and re...
0e3e0c541b56f548bc24aa0d7a72f08cbea4118fe87fbab7209ef2ac50a74a54
Python
3,156
103
#!/usr/bin/env python """ Fit spots for the focus lock using a correlation based approach. Hazen 04/18 """ import numpy import storm_analysis.sa_library.fitting as fitting import storm_analysis.sa_library.ia_utilities_c as iaUtilsC import storm_analysis.sa_library.matched_filter_c as matchedFilterC import storm_analy...
61fc41e541a366bd0c8c34b91ac552e32f70b6be8ed405c59130fba44003af01
Python
3,157
68
# -*- coding: utf-8 -*- """ Created on Tue Jun 15 13:53:06 2021 @author: Yoshi """ from PIL import Image,ImageDraw,ImageFont from cell_drawer import * def cell_number_mapper(tonotopic_map_output_path,canvas,width,height,cell_locations,scale,radius,cell_flags,extra_flag): # Makes a copy of the canvas ...
db20de0fef9d7a36d445f0f721a20ff50d5c56f592c0f823bca07a9ed1c43b83
Python
3,158
93
import os import json import pandas as pd from tqdm import tqdm dataset_path = '../../datasets' dataset_list = os.listdir(dataset_path) dataset_list = ['Twibot-20', 'cresci-2015', 'cresci-2017'] class User: """Class of a User""" def __init__(self, userid: str): self.userid = str(userid) self...
c1564aabdddab0503efeb5680a47b08bda16e23ecbf9e6d374e10abbc9f3752b
Python
3,159
84
# -*- coding: utf-8 -*- """ Written by Guido Meijer """ from powerpixels import Pipeline import os import numpy as np from datetime import datetime from pathlib import Path if __name__ == "__main__": # Initialize power pixels pipeline pp = Pipeline() # Search for process_me.flag print('Lo...
a8ef1603e436d883f452c5c561862ed990cda041c2c1dde75ed7df2704f28ed9
Python
3,160
87
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Transform Nifti (.nii.gz) using an affine/rigid transformation. For more information on how to use the registration script, follow this link: https://scilpy.readthedocs.io/en/latest/documentation/tractogram_registration.html """ import argparse import logging import...
c35dfac7c8141e6efaa28f2b4187b20d5575d789eb12116df7f015f9285a729e
Python
3,160
102
import hashlib from pathlib import Path import subprocess as sp import shutil try: from rich import print except ImportError: # pragma: no cover - optional dependency for nicer CLI output pass def calcHash(filepath): return hashlib.md5( open(filepath, 'rb').read() ).hexdigest() def shipResu...
c87e220b58e05583023425a75de17948e3dcd13803787292323e7950726a62c4
Python
3,160
94
import os import numpy as np parallel_starts = 8 available_gpus = available_gpus = ['4,6', '4,6'] # args dict args_dict = {'device': 1, # gpu 'log_steps': 1, 'num_layers': 3, 'hidden_channels': 256, 'dropout': 0.0, 'batch_size': 64 * 1024, 'lr': 1.e-...
45298bbfc1f4017cbb3ee26d198014210c7533fc8da34746c4a7f19e904a2265
Python
3,161
106
from typing import Callable, Dict, Tuple from magicgui import magicgui from qtpy import QtCore from qtpy.QtWidgets import QMessageBox, QPushButton, QVBoxLayout, QWidget class Affine2DWidget(QWidget): def __init__(self, controller): super().__init__() self.controller = controller self.pa...
5eede358e2e9e05d681f063cc91e2b53ebc1e7e5899b8af36642b5b2bfcce165
Python
3,161
97
import pytest import numpy as np from nems.layers.weight_channels import ( WeightChannels, WeightChannelsGaussian, WeightChannelsMulti, WeightGaussianExpand ) def test_constructor(): with pytest.raises(TypeError): # No shape wc = WeightChannels() with pytest.raises(TypeError): ...
b1acd7bf3c5bd376a9da5fab7b908a75faf35b1ed6422bc56401d52625217084
Python
3,161
75
from src.wrappers.OsipiBase import OsipiBase from src.original.fitting.OGC_AmsterdamUMC.LSQ_fitting import fit_least_squares, fit_least_squares_array import numpy as np class OGC_AmsterdamUMC_biexp(OsipiBase): """ Bi-exponential fitting algorithm by Oliver Gurney-Champion, Amsterdam UMC """ # I'm thin...
fc88b9129b2a40ca090ab235d58913b744140a606b4edee98755f160349f71b4
Python
3,161
87
import numpy as np import seaborn as sns from tqdm import tqdm from argclz import AbstractParser from neuralib.io import csv_header from neuralib.plot import plot_figure from neuralib.util.verbose import publish_annotation from rscvp.spatial.main_cache_occ import ApplyPosBinCache from rscvp.util.cli import DataOutput,...
b7572418cf6d694787fe96bf138e4f168276af1c6a00d5df3a4051cd17bc6bed
Python
3,162
77
from matplotlib import pyplot as plt import numpy as np from numpy import ndarray from typing import Union import cv2 __all__ = ['label_cmap', 'random_colors_hsv'] def random_colors_hsv(num, hue_range=(0, 180), saturation_range=(60, 133), value_range=(180, 256), ubyte=False): colors, = cv2.cvtColor(np.stack(( ...
3db572a644a010cb659ab3dc2db6050c497db894a33ac7f50aa699de745cd095
Python
3,163
90
#!/usr/bin/env python """ Python interface to the LMMoment object finder. This object finder works by indentifying local maxima, then computing their first moment. Note that the maximum number of objects found per image is limited to 1000. Hazen 09/13 """ import ctypes import numpy from numpy.ctypeslib i...
fd9028022775c64e7946650483b622149fa7761ee2a505622066a8ea3672ca6b
Python
3,163
98
from copy import deepcopy from typing import TYPE_CHECKING import pytest from eir.data_load import label_setup from eir.setup.output_setup import get_output_name_config_iterator from eir.setup.output_setup_modules.tabular_output_setup import ( set_up_num_outputs_per_target, ) if TYPE_CHECKING: from eir.setup...
2db9e1f6aca9e4a188174f404e13874abdf29566927c9f98771a832ee4fb72c5
Python
3,164
100
''' Registering high resolution anatomical images to boost SNR ''' import glob import ants import numpy as np import os import nibabel as nb # Set data path DATADIR = '/Users/sebastiandresbach/data/s1Anfunco/Nifti' # Set subjects to work on subs = ['sub-07','sub-09','sub-10'] # Set sessions to work on sessions = ...
67f785790ca853c3494c6dfa187d50a90bde0c8dd16ce8b595e6512690b682c9
Python
3,164
81
import sys from torch.utils.data import DataLoader from geoseg.models.MixerUnet import reparameterize_model from geoseg.losses import * from geoseg.datasets.segpc import SegPCDataset from geoseg.models.Unet import UNet from catalyst.contrib.nn import Lookahead from catalyst import utils from torchinfo import summary ...
eea78bb19940536c7931fba8786c264ed172f992885c5d2138f6d478bf01c705
Python
3,166
76
import warnings warnings.filterwarnings("ignore", message="It is not recommended to directly access") import os import pickle import json import datetime def save_dataset_split(train_dataset, valid_dataset, test_dataset, dataset_name, seed, split_dir='./dataset_splits'): os.makedirs(split_dir, exist_ok=True) ...
5e0065053e0c77c2d843beec0cdb23d954d5f3d7da986210c45674f7902ecc99
Python
3,168
116
import io import os import re import sys from shutil import rmtree from typing import Tuple, List from setuptools import Command, find_packages, setup # Package meta-data. name = "PhaseNet" description = "PhaseNet" url = "" email = "wayne.weiqiang@gmail.com" author = "Weiqiang Zhu" requires_python = ">=3.6.0" current...
fce48067fae606c8d7d6e84f32c00dfb8f683825251eb626013c6e2256cafd2b
Python
3,168
87
# -*- coding: utf-8 -*- """ This file contains the script for defining characteristic functions and using them as a way to embed distributional information in Euclidean space """ import cmath import math import matplotlib.pyplot as plt import numpy as np import seaborn as sb def plot_characteristic_function(phi_s, bu...
559448786156fd332a7c9ea1f8a386e69f58de295ca071dc6384b6151eb893ce
Python
3,169
67
import argparse import utils from os.path import basename import numpy as np from os.path import join ''' for an ensemble or set of models, analyze attribution scores (saliency or shap) if rmse flag set: calculates Euclidean distance as RMSE (must provide reference file) if var flag set: calculates variance in attribu...
f4bd02041bf5afa640bb12253018815182b2c99a33daf6e1bbcaa1aa4d909e00
Python
3,169
85
# This file was automatically generated by SWIG (https://www.swig.org). # Version 4.3.1 # # Do not make changes to this file unless you know what you are doing - modify # the SWIG interface file instead. from sys import version_info as _swig_python_version_info # Import the low-level C/C++ module if __package__ or "."...
07aab11bf3e428057f177c261371d43ccd90083c6d033b2e0824cdfe2dcd9798
Python
3,170
101
#!/usr/bin/python3 # import os import sys import argparse import numpy as np from sklearn.neighbors import NearestNeighbors from uac import utils # Create the parser my_parser = argparse.ArgumentParser(description="UAC scalar mapping") # Add the arguments my_parser.add_argument("target_path", metavar="path", type=st...
28d4183d8944783b2c2208e8588a65a7b73adc58c88a23d1ef3ecba629b05e7c
Python
3,171
63
import torch import torchvision import torchvision.transforms as transforms datapath = './datafile' def get_indices(dataset,class_name): indices = [] for i in range(len(dataset.targets)): if dataset.targets[i] in class_name: indices.append(i) return indices def DLTrain(idx...
b753f18f1b97a804b0611a3d376d1887dbfcf7fb8a7569bb17abf20b988a4fda
Python
3,171
101
import platform import shutil from pathlib import Path from typing import Optional from brainglobe_atlasapi.utils import check_internet_connection from paquo import settings as paquo_settings from paquo.jpype_backend import find_qupath from brainways.utils.paths import get_brainways_dir def get_brainways_qupath_dir...
d8e89bcb93aa6656771e23fd227d2f20d6d8b642735140dca32a22a4510b6925
Python
3,171
76
from torch.utils.data import DataLoader from geoseg.losses import * from geoseg.datasets.ham10000 import HAM10000_Dataset from geoseg.models.deepunet.DeepUnet import Model from catalyst.contrib.nn import Lookahead from catalyst import utils CLASSES=('background', 'foreground') # training hparam max_epoch = 100 ignor...
271f2044c486a7e2357186a29ef5a2eba53171370d9c3c33b793bf513de99d23
Python
3,172
94
import os import numpy as np parallel_starts = 8 available_gpus = available_gpus = ['0,7', '7,0'] # args dict args_dict = {'device': 7, # gpu 'log_steps': 1, 'num_layers': 3, 'hidden_channels': 256, 'dropout': 0.0, 'batch_size': 64 * 1024, 'lr': 1.e-...
9f936268211c98dae1b2dc506a202644cd4c2377888d1c1869d15df4abda3b1d
Python
3,172
93
# Source: https://github.com/neuraloperator/neuraloperator/blob/main/neuralop/layers/segment_csr.py from typing import Literal import importlib import torch from torch import einsum def segment_csr( src: torch.Tensor, indptr: torch.Tensor, reduce: Literal["mean", "sum"], use_scatter=True, ): """...
d34d88ed7d14ff300a10b5de5d1ff3978640cbbfd4335401b66c1be61f2fdd84
Python
3,173
59
import sys sys.path.append('..') from torch import nn from torch_geometric.nn.models.attentive_fp import GATEConv from torch_geometric.nn.conv import GATConv from layers.fastegnn import FastEGNN from layers.conv import ConvBlock from layers.egnn_pyg import EGNNConv class ConvBlockPyG(ConvBlock): def forward(self, ...
fb1cc937f147ca7ca8089ebcfaeb31e83348f61040c248602da75502a26e891c
Python
3,173
98
# %% ### import modules from pathlib import Path import pandas as pd # %% read results table results_dir = Path(__file__).resolve().parents[1] / "results" # %% data df = pd.read_excel(results_dir / "long_c_results.xlsx") # %% round intercept and coef to 3 decimal places. same for intercept_ste and coef_ste df["odds"...
fd3016db4d80c765f122378f97e250300a22f413bac00c5b0f03cad4a6b2d4db
Python
3,173
89
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Conversion of '.tck', '.trk', '.fib', '.vtk' and 'dpy' files using updated file format standard. TRK file always needs a reference file, a NIFTI, for conversion. The FIB file format is in fact a VTK, MITK Diffusion supports it. """ import argparse import logging impor...
1686c60af6e8bc1f0d3cdbbd1b88045f5015a580183bbf3a8726db39396432ab
Python
3,174
72
################## PURPOSE ################# # This script is to restructure the 4th(start pos), 5th(end pos), 6th(copy number), and 7th(seg.mean) columns of the input file # Because these columns hold the "raw" coordinates of the CNV after filtering out for IGLL, telomerics, centromeric # and segup regions, we want to...
240fa286865290180014fcd69756638b8d31dc8293fbe1684129eef619245a09
Python
3,174
87
""" Cropping functional images to decrease number of voxels (and therefore processing demands) """ from nipype.interfaces.fsl import ExtractROI import glob import os # Set data path ROOT = '/Users/sebastiandresbach/data/s1Anfunco/Nifti' # Set subjects to work on subs = ['sub-12', 'sub-15', 'sub-16', 'sub-17', 'sub...
86c8ac9bde4c205d875561da767596e1ddeaacf09d6edd6ea488a07e71b6caf7
Python
3,174
58
from dtiplayground.dmri.common.tools.base import ExternalToolWrapper class ResampleDTIlogEuclidean(ExternalToolWrapper): def __init__(self,binary_path= None, **kwargs): super().__init__(binary_path, **kwargs) def filter_dti(self, inputfile, outputfile,correction='zero'): arguments=[inputfile,...
d6f20aa88593cd9dbf996d04d281dbdc4fd213af34a4eae1ed65284b1ac4c160
Python
3,174
122
import os.path as op import random import tempfile import numpy as np import numpy.testing as npt from AFQ.models.csd import fit_csd from AFQ.models.dti import fit_dti from AFQ.tractography.tractography import track from AFQ.tractography.utils import _is_int from AFQ.utils.testing import make_tracking_data seeds = n...
7b0a9b92a6b402a8400869a2cf723c6b4608b145c9af087197220c980bcebdf2
Python
3,175
96
#!/usr/bin/python3.8+ # -*- coding: utf-8 -*- # @Time : 2022/3/4 10:16 # @Author : Z.-H. G. # @Email_0 : guozhenhao17@mails.ucas.ac.cn # @Email_1 : guozhenhao@tongji.edu.cn # @File : loss.py # @IDE: PyCharm import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Variable ...
aa526761b9a9fc8d286045db15ab9ad037b291baf507c43b1e230d19bd40309d
Python
3,175
70
import os import subprocess import nibabel as nib import numpy as np from nipype import Node, Workflow from nipype.interfaces.utility import IdentityInterface, Merge from ...bids_data.rename_bids_file import rename_bids_file class SCNPipeline: def __init__(self, subject, session,...
ded0c3b1958335cc9bde5e70fc8919c8f2c088a883c63787b61320604b6ceb13
Python
3,176
67
#!/usr/bin/env python3 # Author: Francois Aguet import argparse import os import struct import subprocess from datetime import datetime import contextlib @contextlib.contextmanager def cd(cd_path): saved_path = os.getcwd() os.chdir(cd_path) yield os.chdir(saved_path) parser = argparse.ArgumentParser...
0f9c5da72e121f4152a64fd75c59e472807fba0a9bcb9051c236248564e0aeb0
Python
3,177
117
import lmfit import numpy as np import pandas as pd import impedancefitter as ifit from impedancefitter.time_domain import ( calculate_impedance_spectrum_using_cwt, calculate_impedance_spectrum_using_fft, fit_impedance_from_time_domain, ) data = pd.read_csv("MEA_signal.zip") time = data["time"].to_numpy()...
9c41ea88f76b4776f5a7f50d9c401ad8276e6ee99f7fb33b14303244f90cbd34
Python
3,177
97
import os from pathlib import Path from typing import Optional import dotenv import pytorch_lightning as pl from omegaconf import DictConfig, OmegaConf def get_env(env_name: str, default: Optional[str] = None) -> str: """ Safely read an environment variable. Raises errors if it is not defined or it is em...
693b637f1f7d4871d569dd34509d9dc4c4fca04a98402bd2c12ad7f139542f52
Python
3,178
101
import torch from reducers import DivisorReducer from utils import common_functions as c_f from utils import loss_and_miner_utils as lmu from losses.base_metric_loss_function import BaseMetricLossFunction class MarginLoss(BaseMetricLossFunction): def __init__( self, margin=0.2, nu=0, ...
979d2028c1a4d7fdd519181a0bf390e37ff53f0abe62dd304f6f2e42d6466ad1
Python
3,178
94
#!/usr/bin/python # This script is a slightly modified version of the original found at # # http://wiki.wxwidgets.org/Embedding_PNG_Images-Bin2c_In_Python # # without any copyright attribution so it is assumed it can be used under # wxWindows licence as the rest of the wiki material. import sys import os import...