sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
a0333d4e575bd6b90c40e47424ce6d439e3e5958b7182874e92ed07aa9b2993d
Python
7,826
187
import argparse import os import time from datetime import datetime import numpy as np from skimage.metrics import peak_signal_noise_ratio, structural_similarity from torch.utils.tensorboard import SummaryWriter from inr import models from utils import * import torch import skimage from scipy.ndimage import zoom import...
12ba4ad37c49375f096d40bff5ba445db9cd739dc797f7b0a183fc9765adf101
Python
7,827
263
#!/usr/bin/env python # # make_page.py creates a HTML page with links to files in given directories # # Copyright FJ Nedelec, 14.12.2007 -- 4.2015 & 7.3.2022 """ Synopsis: Generates an HTML page linking images & movies found in sub-directories Usage: make_page.py [recursive=1] [tile=INT] [width=INT] [he...
56194162ee79e7b9e1dcc7b63263e1a1e74a87c93798addeb303b2c222bf9b9d
Python
7,827
217
import sys import yaml import os import numpy as np import matplotlib.pyplot as plt import matplotlib as mpl pathpath,run1,run2,stag1,stag2,ncluststr1,ncluststr2, cmethod = sys.argv[1:] stags = [stag1,stag2] ''' pathpath = 'PATHS/filepaths_carlen.yml' run1 = 'runC00dMP3_brain' run2 = 'runCrespZP_brain' stags = ['spo...
b5914b48ff4cc2e12a3261ad47f1f5b10f69ede774a27473e663987b5730bf9b
Python
7,830
252
import os import shutil from dataclasses import replace from pathlib import Path from typing import List, Tuple from unittest.mock import Mock, create_autospec import napari import numpy as np import pytest import torch from brainglobe_atlasapi.structure_class import StructuresDict from PIL import Image from pytest im...
7f7107b42f5d3fd6339146bf461acb5bc08dbce1b7c5014f859add7bab61317c
Python
7,831
233
import functools import time as pytime from pathlib import Path import click import numpy as np import pyvista as pv import simple_mri as sm import skimage import SVMTK as svmtk from loguru import logger from panta_rhei.meshprocessing import mesh2xdmf, xdmf2hdf from brainmeshing.utils import ( binary_image_surfac...
a56a39abcacb352694d9f102a4fecbf13fda8abb5aba48ceced2f216cd8abdfc
Python
7,831
210
from typing import List, Optional, Union import torch import torch.nn.functional as F from torch import Tensor from torch.nn import Parameter from torch_geometric.nn.inits import ones, zeros from torch_geometric.typing import OptTensor from torch_geometric.utils import degree, scatter class LayerNorm(torch.nn.Modul...
c0d0db41e771396f6ae22773bd463949a4c41052de104ff1e22a5e7b124c7bc6
Python
7,831
213
#!/usr/bin/env python """Direct Globus Transfer + Globus Compute demo. Stages the 5 .xyz fixtures to a remote HPC collection via Globus Transfer, then runs MACE ``driver="thermo"`` on each pre-staged file through Globus Compute. Workers read the structures from the HPC filesystem (remote-path mode), not embedded inlin...
a680ab5a110d4c495694fa7bf69ae187af7c0d1e9bf5056cdde3e33e73e61e66
Python
7,832
162
import numpy as np from itertools import product from scipy.stats import ttest_1samp, ttest_rel from scipy import stats import matplotlib.pyplot as plt import seaborn as sns from utils.const import (SUBJECTS, LABEL_NAMES, CHANCE_LEVEL) class PlotResults: """ Class for plotting decoding results. """ de...
a9539cad9ce409d288de57516bdc7b02e8a392e16bd24ac14aed0afd8a7bb233
Python
7,834
188
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import torch from torch import nn from torch.nn import functional as F from typing import Any, Dict, List, Tuple from .i...
fc7f1da9916cc274e84f3ba1b66b4fc77f0ea518ee4213b7e231d09b57b32804
Python
7,835
177
############################################################################# # Copyright (C) 2020-2026 MEmilio # # Authors: Maximilian Betz # # 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 Li...
4051925585cc3fe5b97351f7672d52c6c25d4ab6276fe1b43241b84dcfd7904e
Python
7,836
191
# Copyright (c) 2022, 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, # WITHOUT W...
98c5f468499b004bacbff4c76c0e49b0a1c1b9522ac1216536719aac6b34f5f4
Python
7,836
166
"""Score spike sorters against synthetic ground truth on a low-density MEA. This is what picks MEA-NAP's default sorter and validates its presets and curation floors — see python/SPIKE_SORTING_PLAN.md §5. Run it after touching ``pipeline/spike_sorting.py``:: uv run python python/benchmark_spike_sorting.py --out l...
57c617c7109a6f556725e02331ca35baa638a6e86378bf6168e19f4fc2668824
Python
7,838
161
import pathlib import h5py import matplotlib import numpy as np matplotlib.use('Qt5Agg') import matplotlib.pyplot as plt from postprocessing_modules.axonal_delay_kernel import get_axonal_delay_kernel from helper_functions import __file__ from helper_functions.plotting_lib import round_sig_decimal MODULE_BASE = pathli...
23d8983f5741722aedc9ca80c129adcde1ee31a41aff6298e3e23b3295b7a5e8
Python
7,840
226
import click as ck import pandas as pd from deepgo.utils import Ontology, propagate_annots import torch as th import numpy as np from torch import nn from torch.nn import functional as F from torch import optim import copy from torch.utils.data import DataLoader, IterableDataset, TensorDataset from itertools import cyc...
052c82e14bc35a545126379451e8e3af58349ea516f7e5437b0b696dba0b44e5
Python
7,842
223
"""Normalization layers for 2D feature maps.""" from typing import Any, Union import numpy as np import torch from torch import nn __all__ = [ 'SpikingBatchNorm2d', 'SpikingEiNorm2d' ] class SpikingBatchNorm2d(nn.Module): """Batch normalization wrapper.""" def __init__(self, num_features: int, eps: fl...
40830f4b6060f3d0f7fa83a013f0bd6e7a2b298c02658b762aecaf644d6404ea
Python
7,842
224
import json import argparse from chemgraph.tools.ase_tools import run_ase from chemgraph.tools.cheminformatics_tools import smiles_to_atomsdata from chemgraph.models.ase_input import ASEInputSchema import datetime import subprocess def get_atomsdata_from_smiles(smiles: str) -> dict: """Return a workflow of conver...
6eb0de7effd0f8ed119217656e6a708e649324e4187601b2e720822171ca87b8
Python
7,845
215
# Copyright 2016 Numenta Inc. # # Copyright may exist in Contributors' modifications # and/or contributions to the work. # # Use of this source code is governed by the MIT # license that can be found in the LICENSE file or at # https://opensource.org/licenses/MIT. class ContextOperator(object): """ ...
56c01c0b4945d4753a20370062a582eea691d8f407066e1618e0dabfdb7302d7
Python
7,849
233
"""Defines functions for ADMET-AI plots.""" import re from io import BytesIO import matplotlib.pyplot as plt import numpy as np import pandas as pd import seaborn as sns from rdkit import Chem from rdkit.Chem.Draw.rdMolDraw2D import MolDraw2DSVG from admet_ai.admet_info import ( get_admet_id_to_units, get_ad...
7ba591bc7d59a5a5d8e647eecb6f8be5f50d881db29a6be347b55346303f4d2f
Python
7,849
181
import pandas as pd from pathlib import Path from pkg_resources import resource_filename from natsort import natsorted from tifffile import tifffile from napari_dmc_brainmap.registration.sharpy_track.sharpy_track.model.calculation import fitGeoTrans, mapPointTransform from napari_dmc_brainmap.utils import get_bregma, ...
516b8134c5ec2868f52b509b010a45c9ba25da42ea8fcf60ec6a4889a333e095
Python
7,858
236
import os import csv import pandas as pd import numpy as np import glob from PIL import Image from tqdm import tqdm from pathlib import Path import numpy as np import staintools import pandas as pd from PIL import Image import torch from torchvision import models from torchvision import transforms from torch.utils.d...
80491603fab912bc62336d19811d4f7b52c9d4cc97d3ac3da195596c01ed4673
Python
7,858
237
import unittest import numpy as np import sigpy as sp import torch import torch.nn as nn import torch.optim as optim import torch.testing as ptt from deepdwi import fourier, lsqr from deepdwi.models import mri from deepdwi.dims import * if __name__ == "__main__": unittest.main() devices = [torch.device('cpu')...
d4dbedbaa87e30ca3f2be3f8f80ed450b87129f2d6cc055d181ac1368125d378
Python
7,858
214
#!/usr/bin/env python """ QGraphicsView customized for displaying camera images. Hazen 3/17 """ from PyQt5 import QtCore, QtGui, QtWidgets class QtCameraGraphicsView(QtWidgets.QGraphicsView): """ This is responsible for handling the camera transforms (flip_horizontal, flip_vertical, transpose). Hopefull...
3762b68189cf9bf70495f22ca01d5f0f458f118774bd053b9bd83c646954f2ee
Python
7,860
215
#!/usr/bin/python3 # import os import sys import argparse import numpy as np from uac import utils # Create the parser my_parser = argparse.ArgumentParser(description="Calculation of old atrial coordinates") # Add the arguments my_parser.add_argument("target_path", metavar="path", type=str, help="Path for the new ta...
4bd9bd69551d404ec19c248598e2e76d1b20a4d2aaae49f2569e22dc87e49573
Python
7,860
255
from collections import deque, Counter import warnings import pandas as pd import numpy as np from xml.etree import ElementTree as ET import math BIOLOGICAL_PROCESS = 'GO:0008150' MOLECULAR_FUNCTION = 'GO:0003674' CELLULAR_COMPONENT = 'GO:0005575' HAS_FUNCTION = 'http://mowl.borg/has_function' FUNC_DICT = { 'cc':...
a682f015832a677851ef84bcaf17e4d1b713e105c52c974d3a0a5c50049cedfd
Python
7,860
223
from collections import Counter from collections.abc import Iterable, Sequence from statistics import mean from typing import TYPE_CHECKING import numpy as np import torch from torch.utils.data import WeightedRandomSampler from eir.utils.logging import get_logger if TYPE_CHECKING: from eir.data_load.datasets imp...
a30dd22aab87d76d395cc7580c02634e576d605044c2d8544f8f1e67ac666f20
Python
7,862
209
from cc3d import connected_components from numpy import unique, delete, zeros, isin, hstack, asarray, argmin, array, where from numpy import min as npmin from numpy import sum as npsum from scipy.spatial.distance import cdist from vg import normalize, perpendicular, angle, basis from scipy.spatial.transform import Rota...
78d152fe61cde65d66cec568f0f2559b6d6b7ba2d7febe140d711279d38c260d
Python
7,864
210
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import init from model.coatnet import conv_3x3_bn, MBConv # 确保这两个函数已定义 # ====================== # 激活函数和 SE 模块 # ====================== class hswish(nn.Module): def forward(self, x): return x * F.relu6(x + 3, inplace=True) /...
d51b13f88d0327077a9b142b164979acf65b5ce69e5957b241c1672e4060f0a4
Python
7,864
207
"""Perform multidimensional scaling (MDS) on NSD-synthetic's and NSD-core's (scan sessions 10 and 20) fMRI responses of all subjects and of all vertices with ncsnr above a threshold. Parameters ---------- subjects : list List of the used NSD subjects. ncsnr_threshold : float Lower bound ncsnr threshold of the kept v...
fc38404d95c7d4d7e4aedb7de4e9e1272eecb7fe9e3753e5898fea65de5d6ec1
Python
7,865
211
import copy import os from pathlib import Path import numpy as np import pytest import torch from mcmlnet.utils.caching import ( np_cache_to_file, torch_to_np, ) class TestTorchToNp: def test_torch_to_np(self) -> None: """Test conversion from torch tensors to numpy arrays.""" t = torch.t...
93ba46c4d43dc938b9b7a4b42a07bf3db488b2cea5be34e2e332c5a44034c0d5
Python
7,869
257
""" This module contains functions for visualizing training results, such as parameter marginals and spectra. """ import matplotlib.pyplot as plt import numpy as np import torch from mcmlnet.utils.logging import setup_logging from mcmlnet.utils.process_spectra import coeff_of_variation from mcmlnet.utils.tensor impor...
d09454e20dfa9a3bc153788fa9a32eca9160d610aaa587b10f5f303ae62d29f5
Python
7,870
209
import os import sys import pprint import torch from torchdrug import core from torchdrug.utils import comm from torch.utils import data as torch_data from torchdrug import data, core, utils import pandas as pd sys.path.append(os.path.dirname(os.path.dirname(__file__))) from biopathnet import dataset, layer, model, ...
b8660654f579cd36eb9e519929444b934df719c25b8fcfe0e91da99a550a125a
Python
7,871
161
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Mar 30 09:58:35 2025 @author: loesch """ from chiCa import * import chiCa import matplotlib.pyplot as plt plt.rcParams["font.family"] = "Arial" from labdatatools import * import os from glob import glob from scipy.ndimage import zoom #%%---Load the da...
d35fea81b6018d6832d5f5cd284fe374efb6b8ea4d7e7e3250c6d4263d163407
Python
7,871
195
import pytest import os from bannotator.data import Annotation import numpy as np TEST_ANNOTATION_FILE_LARGE = os.path.join("tests", "annotation", "annotation.txt") TEST_ANNOTATION_FILE_SMALL = os.path.join("tests", "annotation", "annotation_small.txt") TEST_CONFIG_FILE = os.path.join("tests", "annotation", "config.tx...
b489c0f057cb77de65c1dc810bfe738de881abf167781d90a5afe6a07ea1427a
Python
7,872
160
from numpy import float32, expand_dims, array from skimage.io import imread, imsave from ants import from_numpy, registration, apply_transforms from re import sub from os.path import basename, dirname from tifffile import TiffFile from tqdm import tqdm from os.path import exists from novas3d.utilities import get_mov_fi...
593ea9cd19b73236a4763cef279158f0b62f39da6a57e795db1eeebff66a1110
Python
7,876
238
from __future__ import annotations import shutil import zipfile from io import BytesIO from pathlib import Path from typing import ClassVar, Dict, List, Tuple import requests from loguru import logger from rich.progress import Progress, SpinnerColumn, TextColumn ATLASES_FOLDER = Path(__file__).parent.parent / "regis...
a878a50ec51737747fe34340436532999dd73aa64d763caadf206d89bb6aa8cf
Python
7,876
229
""" Configuration management for ChemGraph Streamlit app. """ import copy import toml import os from pathlib import Path from typing import Dict, Any, Optional from chemgraph.utils.config_utils import flatten_config as _flatten_config from chemgraph.utils.calculator_defaults import get_default_mace_calculator_type CO...
bcde53a16b9bada1638fac20e479816d9854e489c846bddc69e5cf8d51ec9998
Python
7,876
215
""" This is ported from Matlab code from the original TDR codebase. """ import numpy as np import pandas as pd import copy def average_conditions(data, conditions): task_index = {} for key, value in conditions.items(): unique_values, indices = np.unique(value, return_inverse=True) task_index[...
ea69c948d8a5e2e0849ae41baeace887b59145182598262a5c6acafdd6364a6b
Python
7,876
233
#!/usr/bin/env python """ RS232 interface to a Zaber XY stage. Hazen 04/17 Jeff 04/21 """ import traceback import storm_control.sc_hardware.serial.RS232 as RS232 import storm_control.sc_library.hdebug as hdebug class ZaberXYRS232(RS232.RS232): """ ZaberXY stage RS232 interface class. """ def __init_...
c4e201ad96f1b904b7c2a094f79fa5ad79f8c5d87b37f3ae18f6e915d4fdfcb4
Python
7,877
150
import os import json import ijson import argparse import pandas as pd import numpy as np from feature_engineering import feature_preprocess from feature_twibot22 import preprocess from feature_supplement import preprocessing from sklearn.ensemble import RandomForestClassifier from sklearn.metrics import accuracy_score...
f77d5207ea4a1c3f099ce412bf1b0e36a42164de6771aa8202bcfa57d99075fa
Python
7,878
198
# -*- coding: utf-8 -*- """ Created on Fri May 29 09:25:58 2020 文本分类 双向LSTM + Attention 算法 @author: """ import copy import torch import torch.nn as nn import torch.nn.functional as F from data_processor import DataProcessor torch.manual_seed(100) #保证每次运行初始化的随机数相同 vocab_size = 50000 #词表大小 embedding_size = 25 #词向...
31bc62026eae791910fe3ab88ef1b88b6c8572d4a5942f4d800c5116e2688247
Python
7,879
213
import tensorflow as tf from tensorflow.keras.losses import Loss class MyLoss(Loss): """ A custom TensorFlow loss that computes exchange-correlation (XC) energies for multiple test sets and molecules, using model predictions. The loss internally: 1) Splits predicted tensors to compute average XC ...
318bf81030558863a4ec6effea3c9d063a297f299367e379a58b89c24e3f421f
Python
7,881
168
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license import numpy as np from ultralytics.utils.metrics import batch_probiou, bbox_ioa try: import lap # for linear_assignment assert lap.__version__ # verify package is not directory except (ImportError, AssertionError, AttributeError): fr...
5d5f6e700e9b69e1250c514130b12c44e1cd9f9a17b2b088a92b8f36029b07d3
Python
7,883
243
# Imports import glob from pathlib import Path import numpy as np import numpy.typing as npt import pandas as pd import ase.io import joblib import pickle from modules.build_data.fhi_aims.crosscheck_names import crosscheck_parts_with_xyz from modules.tools.system_cutoff import find_closest_atoms_to_mol from modules....
9893add2d17329eb506c8d42e5d5846e942497f2b4872913d37f43b25d1cf185
Python
7,885
223
"""Plot data extractors. The responsibility of these classes is to extract the data from the EvaluationResults objects to match the requested plot. """ import abc from sklearn import metrics from . import curve_data_makers, plots from ...metrics.weight_metrics import calculate_covariate_balance class BaseEvaluati...
beb5bc84c224a7690b854dc7f5b0424a4ff22dceae5adfa04ecb69b24da6fe57
Python
7,887
193
"""Cao et al. (2019) sustained-attention driving dataset access layer. Cao, Z. et al. "Multi-channel EEG recordings during a sustained-attention driving task", Scientific Data 6:19 (2019), figshare 10.6084/m9.figshare.6427334 (CC BY 4.0). Twenty-seven participants, sixty-two sessions, 30-channel EEG at 500 Hz in EEGLA...
c2d3fd4a6327f7f1718ba3054290db54566444041a66c54c5473ceb3d7159215
Python
7,889
252
import os import json import torch import optuna import pandas as pd from logits import ( AttentiveNet, GATNet, GINet, MPNNet ) from attentive import AttentiveMod from gat import GATMod from gin import GINMod from mpnn import MPNNMod def load_data(file_path): df = pd.read...
1f57e6d7a4e447bee6765d2b782b6d051868777e97ae09a37c59ba3f38f7d35d
Python
7,890
246
import os import numpy as np import pytest pytest.importorskip("fabio") pytest.importorskip("PySide6") from musclex.utils import file_manager class _ImmediateFuture: def __init__(self, value): self._value = value def result(self): return self._value class _ImmediatePool: def __init__...
91b72de8205b1a7fc7b36fb7e6c633496e5424e20d417f3cac8cacd03d6cfb16
Python
7,891
181
"""Attach the matches ROICaT declined, when position alone settles them. ROICaT clusters on footprint similarity and is conservative about it. Audited over the Mecp2 run (93 chains): for every tracked cell and every day it was missing from, what sat at its expected position in that day's ROIs? =======================...
80eb9deb69f2be6db651ec1aab572b2e876d72cbbf2f9ea719b11eb3351f3d3f
Python
7,892
197
import sys import math import os from PyQt5 import QtWidgets, QtGui, QtCore class ImageWidget(QtWidgets.QWidget): # Signal to communicate updated center coordinates (as text) centerChanged = QtCore.pyqtSignal(str) def __init__(self, image_path, parent=None): super().__init__(parent) # Set...
4dc85e45a90f71f52b0069e4e2f3d1078c1f5f170ab7527e3d6e1f1ef1feaf36
Python
7,895
237
# FetMRQC: Quality control for fetal brain MRI # # Copyright 2023 Medical Image Analysis Laboratory (MIAL) # # 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/licens...
8bacfd1c664b18d96cc41ad7b4374b8c5c5b1fb480ecdd53a5bbfa071cfde9cc
Python
7,896
183
#!/usr/bin/env python # author: Jannes Spangenberg # github: https://github.com/JannesSP # website: https://jannessp.github.io import pandas as pd from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, Namespace def parse() -> Namespace: parser = ArgumentParser( formatter_class=ArgumentDefaul...
7ae36fdb85e7fe65436731ac140951d3f13cb6bce205c677bc12a239dd75663c
Python
7,897
244
import torch import torch.nn as nn from .base import WaveformModel, WaveformPipeline class DeepPhasePick(WaveformPipeline): """ Note: ... """ # TODO: update def __init__( self, in_channels=3, classes=3, phases=None, sampling_rate=100, pred_sample=...
8fccd78e22870e5578ef596447fb193f60e42e77858a3b000f87c1426a2a27eb
Python
7,897
96
from brainscore_core import Metric from brainscore_vision import load_metric, Ceiling, load_ceiling, load_dataset from brainscore_vision.benchmark_helpers.neural_common import NeuralBenchmark, average_repetition, apply_keep_attrs from brainscore_vision.model_helpers.brain_transformation.temporal import assembly_time_a...
15814ad5408089112435de386eec8bd838fccd28bad93e28a618e75767906cff
Python
7,899
182
import pytest pytest.importorskip("fireants_fused_ops") import torch from time import time from fireants.losses.cc import LocalNormalizedCrossCorrelationLoss from fireants.tests.cc_mem_test import fast_lncc from fireants.losses.fusedcc import FusedLocalNormalizedCrossCorrelationLoss # from fused_ops.ops.fusedcc import...
3ce3ebe8b5ae2247660a0010c6d23a757e6861f418949a06a5ae448c0ff362d3
Python
7,899
221
import fcn_megfmri import numpy as np import pandas as pd import seaborn as sns import scipy.stats as stats import matplotlib.pyplot as plt # get custom colormaps cmap_seq, cmap_seq_r, megcmap, megcmap2, categ_cmap = fcn_megfmri.make_colormaps() plt.rcParams['svg.fonttype'] = 'none' plt.rcParams['font.sans-serif'] =...
9a6e0cbd728454b4d4edfde46f9042bb7f3167b78da87f14bda64db2b486bc79
Python
7,902
191
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license from ultralytics.utils import SETTINGS, TESTS_RUNNING from ultralytics.utils.torch_utils import model_info_for_loggers try: assert not TESTS_RUNNING # do not log pytest assert SETTINGS["wandb"] is True # verify integration is enabled im...
7500a31f718ed9baa7e7ace7e287e5d43894b33b2741ea4a34b322ab8d1bd3b8
Python
7,903
280
#!/usr/bin/env python """ This parses a log file series (i.e. log, log.1, log.2, etc..) and outputs timing and call frequency information for HAL messages. Hazen 5/18 """ from datetime import datetime import os pattern = '%Y-%m-%d %H:%M:%S,%f' class Message(object): """ Storage for the timing of a single m...
9eedb2b7b4df2a53db91f7dfbb0964527aa3f80be52b38caf41681445818cb60
Python
7,903
224
# Copyright (C) CVAT.ai Corporation # # SPDX-License-Identifier: MIT import re from unittest.mock import MagicMock, patch from allauth.account.models import EmailAddress from django.core import mail from django.test import override_settings from django.urls import re_path, reverse from django.views.generic import Red...
801d1e158f49530a6d282ba6d4ceaed3bd599819ea0de3781168b5a67926ce7f
Python
7,904
250
class SetConv(torch.nn.Module): def __init__(self, nb_feat_in, nb_feat_out): super(SetConv, self).__init__() self.fc1 = torch.nn.Conv2d(nb_feat_in+2, nb_feat_out, 1, bias=False) self.bn1 = torch.nn.InstanceNorm2d(nb_feat_out, affine=True) self.fc2 = torch.nn.Conv2d(nb_feat_out, nb_...
6c2faa1fb3cd0578c1dde16df81e317cc749a7c74f0f7d9b2b092087e35beacf
Python
7,905
229
import numpy as np import soundfile as sf import matplotlib.pyplot as plt import tkinter as tk from tkinter import filedialog from tkinter import ttk class WaveViewer: """ Class to load audio files and visualize them in time and frequency domains. """ def __init__(self, audio_path: str, channel_mode: s...
41a68f1e9ad43c1026d81526b03e1248bdda06dcec9a7d0d70c528e5ac910a8a
Python
7,908
213
import numpy as np from sklearn.base import BaseEstimator from .alignment import ProcrustesAlignment from .kernels import compute_affinity from .embedding import PCAMaps, LaplacianEigenmaps, DiffusionMaps def _fit_one(x, app, kernel, n_components, random_state, gamma=None, sparsity=0.9, **kwargs): ...
5919688a0fd0b1fef16050f0d4b45dcd4f3dfe429f4259ec4ef4980306a56cfd
Python
7,908
214
import torch import numpy as np import pandas as pd from tqdm import tqdm from datetime import datetime as dt from dataset_tool import fast_merge,df_to_mask import os print('loading raw data') node=pd.read_json("../datasets/cresci-2015/node.json") edge=pd.read_csv("../datasets/cresci-2015/edge.csv") label=pd.read_csv(...
005bc8d98cbda49fb1a1d51474245884e0a333d8d18cbe82b8d68cb0a5b1da7b
Python
7,909
196
'''ResNet in PyTorch. For Pre-activation ResNet, see 'preact_resnet.py'. Reference: [1] Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun Deep Residual Learning for Image Recognition. arXiv:1512.03385 ''' ''' Code from https://github.com/kuangliu/pytorch-cifar ''' # resnet18 adaptpooling 1x4 import torch import t...
1b432acab05cbc9e4876a9f622c8c0470911601a6d1bc439b0daff8d0b61eb1f
Python
7,912
196
import torch from torch import nn from eir.models.input.array.models_cnn import CNNResidualBlock from eir.models.layers.mlp_layers import MLPResidualBlock from eir.models.layers.projection_layers import get_1d_projection_layer from eir.models.tensor_broker.projection_modules.cnn import ( get_conv_params_for_dimens...
a1e975ef008602c0dc11e05cda4942e07abf2e2be14a63e673b77a197b35cf57
Python
7,913
191
import torch import torch.nn as nn from torch.hub import load_state_dict_from_url from typing import Union, List, Dict, Any, cast __all__ = [ 'VGG', 'vgg11', 'vgg11_bn', 'vgg13', 'vgg13_bn', 'vgg16', 'vgg16_bn', 'vgg19_bn', 'vgg19', ] model_urls = { 'vgg11': 'https://download.pytorch.org/models/vgg11-8a...
ac9d86b16dffbae9d0ef266e8bcdef263c5a405bc0561fe46c348e5e7497fc5e
Python
7,916
245
#!/usr/bin/env python """Smoke test for ParslBackend on an HPC compute node. Must run **inside** a PBS interactive allocation on Polaris or Aurora:: # Polaris qsub -I -A <proj> -l select=1 -l walltime=01:00:00 -q debug # Aurora qsub -I -A <proj> -l select=1,walltime=01:00:00 -q debug -l filesystems=ho...
150254f0dd087c021ccba1adfcd747c4bc42a9ed1889ae76ec792b7d13fb1ba7
Python
7,918
284
from copy import deepcopy from typing import TYPE_CHECKING from unittest.mock import create_autospec import pytest import torch from eir.setup.input_setup_modules.torchtext_port.vocab import Vocab from eir.train_utils.evaluation_modules.evaluation_handlers_utils import decode_tokens from eir.train_utils.evaluation_mo...
aee5baf60f06216bceb6cbb528ce29d9fee0ecfd25ad02817eee6fc5e6437d27
Python
7,919
195
# -*- coding: utf-8 -*- """ Functions to gather iamge statistics in large volumetric images The main routines extract information from a large volumetric image, such as the maximum or mean. """ #:copyright: Copyright 2015 by Christoph Kirst, The Rockefeller University, New York City #:license: GNU, see LICENSE.txt fo...
3a6014388d8e1cf92654c6931d523a3f036ed98f00f61c15a67d1a0ae5d8598d
Python
7,920
216
import sys, os, subprocess, argparse, time import numpy as np import util, slurm def task(cmd, jobnum=False, timeout=None, run=True): print(cmd) if run: result = subprocess.run(cmd, timeout=timeout, capture_output=True, encoding='utf-8', shell=True) print(result.stdout) if jobnum: ...
9492a6a15efe88050de555ec8fc2af9d8ade5bf6208e4098cd4b032a57be46d2
Python
7,921
223
import torch import torchvision from torch import Tensor import torch.nn as nn import math import numpy as np import torch.nn.functional as F from torch.hub import load_state_dict_from_url from .functions import ReverseLayerF class ResNet10(torchvision.models.resnet.ResNet): def __init__(self, track_bn=True): ...
b45b94699ceba8c58629672cf5d81373eb193016bfa020a56c501d709ba7010d
Python
7,921
221
import numpy as np from scipy.spatial.transform import Rotation from scipy.interpolate import RBFInterpolator from sklearn.kernel_approximation import Nystroem # Nyström 近似 from sklearn.neighbors import NearestNeighbors def kernel_interpolate( Y, # (N, D) target points y, # (M, D) source points ...
196d603c69ce6be3ed739fb8a8edc7d5031d213b2a7c9b082e0c867c05f9ad65
Python
7,923
237
"""GLM Permutations base class.""" import logging from typing import Dict, Optional import numpy as np from scipy import stats from pqdm.processes import pqdm from tqdm.auto import trange from osl_dynamics.glm.base import Design, GLM from osl_dynamics.glm.ols import osl_fit _logger = logging.getLogger("osl-dynamics...
1a4296f6dc76da3bcb1775b12156fe4a3ef1768b5d381a4855753559117b549c
Python
7,924
182
import numpy as np import matplotlib.pyplot as plt import OptimalBattery.evaluate as ev import Functional_Fusion.atlas_map as am import OptimalBattery.util as ut import OptimalBattery.construct as ct from scipy.optimize import brentq from Functional_Fusion.dataset import DataSetLanguage from scipy.stats import ttest_re...
98d3503e5e1f515b896585014a70dfccb758232c9dcda7b2d323511af0a7749b
Python
7,925
185
import argparse import json import warnings import torch import os import sys import yaml import numpy as np import pandas as pd from torch import nn from torch_geometric.loader import DataLoader from numpy import nan from typing import * from tqdm import tqdm from scipy.stats import spearmanr from transformers import ...
66eb3bced49098c57212b6a4f31238ae3cc4f7886db51d319614fabdbda8ac34
Python
7,927
225
''' C3H7NO ''' import numpy as np import sys def intro(): print(""" SHORT List of potential energy surfaces for C3H7NO: P: potential energy, G: Gradient, D: Nonadiabatic coupling vector This is listed at the end of description to show the availability. For example: P/G means both potential energy...
c5f835ad7c3a95004a73b03cc5b4d43c051314f89163165205f9aeb9ff8f880c
Python
7,927
156
## ------------------------------------------------------------ ## IMPORTS ## ------------------------------------------------------------ import torch import torch.nn as nn from LSTMConvCell import * # Phase Embed Dynamic class PhaseDecoder(nn.Module): def __init__(self, gpu_id, ch_mult): super(PhaseDeco...
7e7fdd9694547e9e0306f02c9fdc72dca69cc677b0777f43415f44d094cccc40
Python
7,930
138
import os class PipelineManager: def get_pipeline(self, pipeline_name, subject, session=None, output_path=None, **kwargs): """ Retrieve an instance of the specified pipeline. :param pipeline_name: str, pipeline name :param subject: BIDSSubject instance :param session: option...
4c2e2b234f7dc79e24ad50175eade2565b877dec48f1449c74908562b0ee508f
Python
7,937
184
#!/usr/bin/env python # author: Jannes Spangenberg # e-mail: jannes.spangenberg@uni-jena.de # github: https://github.com/JannesSP # website: https://jannessp.github.io import pandas as pd from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, Namespace def parse() -> Namespace: parser = ArgumentParse...
0b7345c856d6b644d9bc6c2a90c728411a0ac34cab44133ad4337d528b12ce29
Python
7,938
225
# Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under th...
3654c1080d4ae4a8f94f405fe526259351d6f3a49ce40c21b2c79df1c35cf6b0
Python
7,940
236
import matplotlib.pyplot as plt import numpy as np try: from rsatoolbox.vis.colors import rdm_colormap_classic except: print('[WARNING] rsatoolbox is not installed') try: from nilearn import masking from nilearn import image, plotting except: print('[WARNING] nilearn is not installed') try: impo...
daddec26ff33da33d7cc0ed088c7852802b0c18ca599d6fcbdf2c544fb9c2e24
Python
7,941
223
import torch import tifffile import pandas as pd import numpy as np import os def process_boxes(input_df, tif_path,marker='marker', device=None): """ Process bounding boxes to calculate min and std of expanded regions in a 16-bit TIFF image. Args: input_df (pd.DataFrame): DataFrame containing ...
3e78a56b54e8ebadaee0c0f132aee35364b920af4e195a9bba991d5553d820d0
Python
7,942
191
""" Methods for correcting for signal drift. """ import numpy as np import json from ivim.io.base import data_from_file, file_from_data, read_im def temporal(im_file: str, bval_file: str, outbase: str, roi_file: str | None = None, order: int = 2, ctm: str = 'mean', voxelwise: bool = False) -> None: """ Correc...
5780fcd2dff44fbbd634ec72089c13f75d16d4db93892121f81bad88c39da9b2
Python
7,944
242
#!/usr/bin/env python3 import argparse import re from pathlib import Path import pandas as pd import seaborn as sns import matplotlib.pyplot as plt SAMPLE_COL = "Sample" LEFT_COL = "LeftBreakpoint" RIGHT_COL = "RightBreakpoint" def safe_name(s): """Sanitize a string for safe use in filenames. Replaces char...
c37282302a0204ce3bc8e1f85d40857d6cd941589260477c83be06c18ba4e950
Python
7,946
190
#! /usr/bin/env python """Measure intra-surface distances and optionally verticality for a pycurv-generated triangle graph file. Usage: python intradistance_verticality.py file.gt [options] """ __author__ = "Benjamin Barad" __email__ = "benjamin.barad@gmail.com" __license__ = "GPLv3" import click import vtk import n...
9f7d91020f00a87694b4331c5f2eaa7475a81242247ed097daec52de67b79723
Python
7,947
237
""" Tests for deepreg/dataset/preprocess.py in pytest style Some internals of the _gen_transform, _transform and transform function, such as: - layer_util.random_transform_generator - layer_util.warp_grid - layer_util.resample Are assumed working, and are tested separately in test_layer_util.py; as such we...
da870e70c975591f7aa4523bc3e384a345d4f1fe72fd21cb9657bfc5b37542e4
Python
7,948
243
""" Core data classes and ``FitterAdapter`` protocol for the A/B framework. The schema is intentionally **library-agnostic**: a ``FitCase`` is a pure Python + NumPy snapshot of one fit invocation, plus a frozen reference result. Any adapter (lmfit/scipy/VarPro/iminuit/...) can replay it without touching the original `...
5ff901b3ec399bcf781bd848f5484a2080564c12acebe40027b8f1e0853ff6fa
Python
7,949
203
import os import os.path as op import sys import numpy as np import pandas as pd import matplotlib.pyplot as plt import matplotlib.patches as patches from matplotlib.gridspec import GridSpec import matplotlib.image as mpimg from matplotlib.offsetbox import OffsetImage, AnnotationBbox import seaborn as sns from eelbrain...
e5a0935e473d78709c506ae6d9aebd09deb997372e14254f3706534e6326a3cd
Python
7,949
212
import sys import yaml import os import numpy as np import h5py pathpath,myrun,ncluststr,cmethod = sys.argv[1:] """ pathpath = 'PATHS/filepaths_carlen.yml' myrun = 'runC00dMP3_brain' cmethod = 'ward' ncluststr = '8'# """ with open(pathpath, 'r') as myfile: pathdict = yaml.safe_load(myfile) sys.path.append(pathdict...
7b9ab0c4d852506955a57500e4f9d5d2077d53e829c9596e49a14775f6a4eeee
Python
7,953
259
"""Morphology loading and coordinate-to-volume transformation. SWC is whitespace-delimited but writers disagree on which whitespace: the Allen files use a single space, while MorphIO (v3.3.3 was the version reported in issue #8) pads its columns so runs of spaces separate the fields. Splitting on a literal single spac...
9e4b17e5df61a1862fc9f601707a5c3bd567c4ccb35d0bff9590b31d47f924e0
Python
7,953
202
# 1. link prediction. negative pair and positive pair prediction # 2. prediction result see the correlation pearson and spearman #remember that need to down sample to equal instance from gensim.models.keyedvectors import KeyedVectors import argparse import random import numpy as np from sklearn import linear_model ...
b4a52a27443b5b9a4c9ffc0d9250f4ec134a41875fafe3acaf1fc5f2682bf90d
Python
7,953
198
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license # Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved """Various utility models.""" from __future__ import annotations import math import numpy as np import torch from torch import Tensor, nn class DotProductScoring(torch.nn.M...
f9e3f3fdd9750074b48bf43d10ac497bb2bd08a6ef9eec172a7670bf799e5a00
Python
7,953
211
# script to load the trained model # first, evaluates on the validation and full test set # then evaluates on the validation and test_pred.txt # finally predicts for test_pred.txt # to double check with performances seen during training if all loaded correctly import os import sys import pprint import torch from torc...
e5a6fa57f9c458d272696216c1fa402038ce96f559a1bc4a31da24c6884319f1
Python
7,954
231
# -*- coding: utf-8 -*- # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: """This module provides interfaces for workbench surface commands""" import os from nipype.interfaces.base import TraitedSpec, File, traits, CommandLineInputSpec from nipype.interfa...
3b9d97099d76bb5f39b544719dc9e416fb100eea59e84b61d56c27904920e195
Python
7,956
265
"""Brain-Score wrapper for DeepEISNN EI-SNN CIFAR10 VGG19.""" from __future__ import annotations import functools import json import sys from collections import OrderedDict from pathlib import Path from typing import Any, Iterable import numpy as np if not hasattr(np, "int"): np.int = np.int32 import torch fro...
03ac88d2abd7db8380202a324516e5fa09f7dd30307b553337cf012e4546c683
Python
7,958
292
# 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 bisect import time from collections import OrderedDict from typing import Dict, Optional try: impo...
e9a8236d4c87313cc2bcbabbcb8970447e57263916c3095987e88c8a187e7050
Python
7,959
233
""" Generating structure graphs for graph convolutional neural networks """ import os import argparse from os.path import isfile from enum import Enum, auto import numpy as np from scipy.spatial.distance import cdist import networkx as nx from biopandas.pdb import PandasPdb import constants import utils class GraphT...
e9d016afe68b1650adc3683015965d464bcae56e554283d829a4249dfa0f0136
Python
7,961
185
import os import Bio import Bio.AlignIO import numpy as np import math import torch import seaborn as sns import matplotlib.pyplot as plt import pandas as pd #对每一个序列进行PSSM打分 def pssm(proseq,outdir): # 一个命令函数,依据pdb文件。使用blast生成pssm文件 def command_pssm(content, output_file, pssm_file): os.system('psiblast \...
9f72a0f441b0feeb6425f2254d0d9f65f70c316bde66e78c3cece6fcedff7457
Python
7,964
182
import numpy as np import librosa from scipy import signal def preemphasis(wav, k, preemphasize=True): if preemphasize: return signal.lfilter([1, -k], [1], wav) return wav def inv_preemphasis(wav, k, inv_preemphasize=True): if inv_preemphasize: return signal.lfilter([1], [1, -k], wav) ...
af82b52d696e8d0fe073410134beeef32a342b66abb048761a955ddc942909ef
Python
7,964
221
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Jun 21 18:51:41 2024 @author: costantino_ai """ # Imports necessary libraries import os import logging from pathlib import Path import numpy as np from scipy.io import loadmat from brainscore_core.supported_data_standards.brainio.assemblies import Neu...
d846774bd213aa5ada75597a79c068fc9769f31e246311defa174edb2e6d37d4
Python
7,964
132
import json import numpy as np from copy import deepcopy from napari_dmc_brainmap.registration.sharpy_track.sharpy_track.model.calculation import fitGeoTrans, mapPointTransform from napari_dmc_brainmap.registration.sharpy_track.sharpy_track.view.TreRow import TreRow class MeasurementHandler: def __init__(self, mea...