sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
4a51fbbf9f453071b4dc061cce70c16ccea832910af5ce6cb4830e3c05f277c6 | Python | 4,175 | 100 | from tristan_pipeline.io.params import *
from tristan_pipeline.utils.loading_utils import *
from tristan_pipeline.utils.preproc_utils import *
from tristan_pipeline.utils.analysis_utils import *
from tristan_pipeline.utils.plotting_utils import *
from nilearn.plotting import plot_stat_map
from nilearn import plotting,... |
6a3b73fca3256768afd0dd356a6da74d55e23175eeb74590468c868738099210 | Python | 4,175 | 113 | from pptx import Presentation
from pptx.util import Inches, Pt
from PIL import Image
class PPTImageInserter:
"""
A class to insert images into a PowerPoint presentation in a grid layout, maintaining the aspect ratio of images.
Attributes
----------
grid_dims : tuple
The number... |
f8826f4104170151e0fd59e02a1611d8a434a1494e71c96341a2359796fc0993 | Python | 4,177 | 102 | from typing import Any, Callable, Optional
import numpy as np
import numpy.typing as npt
from hsnn.core.types import SpikeTrains
from hsnn.core.logger import get_logger
from hsnn import ops
__all__ = ["SpatioTemporalPattern", "PolyChronGroup"]
logger = get_logger(__name__)
class SpatioTemporalPattern:
def __i... |
37179634a572588a46a7fec5aa440d4a78e56cc7202cbe595895b1b6ffd3bb09 | Python | 4,179 | 118 | #!/usr/bin/python3
##################################################################################
#
# MIT License
#
# Copyright (c) 2025 Kevin Rockenbach, Agnieszka Golicz
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "So... |
dc1a146aee18adb226b5d5424f896af0f283990020b654be0fbbd003244f6fb9 | Python | 4,184 | 98 | import torch
from nnunetv2.training.nnUNetTrainer.nnUNetTrainer import nnUNetTrainer
class nnUNetTrainer_5epochs(nnUNetTrainer):
def __init__(self, plans: dict, configuration: str, fold: int, dataset_json: dict,
device: torch.device = torch.device('cuda')):
"""used for debugging plans et... |
fe2a277709035a2ff9c3e88bcf0973e287c9dfee23418a82c1b7379e7f04be57 | Python | 4,184 | 122 | import logging
from importlib.util import find_spec
from os import PathLike
from pathlib import Path
from typing import Generator, Optional, Protocol, Sequence, Tuple, Union
import numpy as np
from .. import io
from ._segmentation import SteinbockSegmentationException
try:
from cellpose import models
cellpo... |
ee83673d21fb435c9be388d2534e7e5e73fdf504390c5d656d550202fed63730 | Python | 4,191 | 82 | #!/usr/bin/env python3
"""Record adjudications for the two diagnostic classes this package expects.
Class A, table first pages. Each of Tables 1-7 is emitted whole on its first
PDF page (tooling/apply_review.py rule T), so that page's output carries the
numeric values of the rows the PDF prints on the continuation pag... |
7a1dcb242b9aeaa3a208e740bdeffd9dcfcd1a12a7ef98950ec1c8ae0440cb1f | Python | 4,195 | 86 | from SPIDER import pseudo_spot_generation
import os, scanpy as sc, pandas as pd, numpy as np, pickle
def load_DLPFC():
data_name = "DLPFC_sc_st_ps.pickle" # name for processed data file
save_directory = "path to directory to save processed data"
if os.path.isfile(save_directory+data_name):
with ope... |
4d1e2dc3453aff52b6a5a67be804e6fd1816d95c1c62ccad030d439eaf8677b1 | Python | 4,196 | 126 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the di... |
5ab334e5aaf4589a43ca8e25caf51f51ffc560bc84c1a4b99c7ef3a11e32c8dd | Python | 4,196 | 111 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 7 12:36:31 2022
@author: evanqu
"""
import numpy as np
import gzip
import pickle
import logging
import argparse
from accusnv import log as accusnv_log
from accusnv.preprocessing import utils as ghf
log = logging.getLogger('accusnv')
#%%
def gener... |
6426d06f915f12f0eb5bf4f31f94092b23422d663337a22fc27a8b4ea8630ccb | Python | 4,202 | 133 | import math
import torch
def diou_loss(
boxes1: torch.Tensor,
boxes2: torch.Tensor,
reduction: str = "none",
eps: float = 1e-7,
) -> torch.Tensor:
"""
Distance Intersection over Union Loss (Zhaohui Zheng et. al)
https://arxiv.org/abs/1911.08287
Args:
boxes1, boxes2 (Tensor): bo... |
929837e7d68155576bb79aa21c7e910f78915fb9dc3c3901049d7a46bc888d2f | Python | 4,203 | 125 |
"""
Evaluate Saturn integration results using scIB metrics.
"""
import os
import pandas as pd
import numpy as np
import scanpy as sc
import scib
from scib.metrics import kBET
result_dir = "PATH_TO_OUTPUT_DIR_FOR_ALL_METRICS/"
os.makedirs(result_dir, exist_ok=True)
unintegrated_path = "PATH_TO_UNINTEGRATED_H5AD/"
s... |
72041c5668e93ba59117ad1c7e4189be651ad5fee2a5d73978f56ebc54ddf38e | Python | 4,205 | 95 | #%%
import sys
sys.path.append('/mnt/obob/staff/fschmidt/cardiac_1_f')
from os import listdir
from os.path import join
import pandas as pd
import bambi as bmb
import joblib
from scipy.stats import zscore
import arviz as az
from plus_slurm import Job
import numpy as np
#%%
class StatsAcross(Job):
#%% the run... |
88d1e0735573eba749e5384e927734d2b273dec4e9b4969a17e7e22e02d1be88 | Python | 4,209 | 124 | import os
import numpy as np
import pandas as pd
import anndata as ad
import numpy as np
import scanpy as sc
import time
import glob
import matplotlib.pyplot as plt
from .TSvelo_utils import scv_analysis
def load_branches(args):
adata = ad.read_h5ad(args.save_folder +"/pp.h5ad")
h5ad_file_path_all = glob.glob... |
341f99f2c2bd3821000ab4e1704316230187c62059bf691ba4ed791f03807084 | Python | 4,210 | 111 | import numpy as np
import pandas as pd
from hsnn.analysis.png.base import PNG
from hsnn.analysis.png._utils import isconstrained
TOL = 1.0
W_MIN = 0.5
def _make_syn_params(rows):
"""
rows: list of dicts with keys: layer_post, proj, pre, post, w, delay
"""
df = pd.DataFrame(rows)
df.set_index(['la... |
d782a83ea16010117af68617bfbeb16a3c65fc2ba439d61c48f7a00c15feaeae | Python | 4,218 | 120 | #
# Copyright (c) 2021 10X Genomics, Inc. All rights reserved.
#
"""Websummary code for JIBES models."""
from __future__ import annotations
# sample 100k points for jibes biplot
import numpy as np
from six import ensure_str
from cellranger.analysis import jibes_constants as jibes
from cellranger.analysis.jibes import... |
a583440268004b41b298756d79bedd354344984a5346969c82867e7d09430c6c | Python | 4,219 | 116 | #!/usr/bin/env python3
############################################################################
# Copyright (c) 2022-2026 University of Helsinki
# Copyright (c) 2019-2022 Saint Petersburg State University
# # All Rights Reserved
# See file LICENSE for details.
#######################################################... |
a2bf0c59910f89569a4548cdcc1f248977823f68d2b0aa0c28c9d0a0e241a26e | Python | 4,224 | 140 | """This integration test is designed to ensure that the chemprop model can _overfit_ the training
data. A small enough dataset should be memorizable by even a moderately sized model, so this test
should generally pass."""
import sys
from lightning import pytorch as pl
import pytest
import torch
from torch.utils.data ... |
54b828d0cbf0ad5e40c57749fb765c670f68a702874d57348375754ec6e89685 | Python | 4,225 | 98 | import torch
# FFT & iFFT
def ifftnd(kspace : torch.Tensor, axes : list =[-1]) -> torch.Tensor:
from torch.fft import fftshift, ifftshift, ifftn
if axes is None:
axes = range(kspace.ndim)
img = fftshift(ifftn(ifftshift(kspace, dim=axes), dim=axes), dim=axes)
return img
def fftnd(img:torch.T... |
47fc97db3993f7c92d6759362f69b5032fb444f4c27573acc01a4c9b02a0fb78 | Python | 4,226 | 118 | import os
import time
import json
import pandas as pd
import openai
from dotenv import load_dotenv
from openai.error import RateLimitError, APIError, APIConnectionError
# --- Configuration ---
load_dotenv(override=False)
openai.api_key = os.environ.get("OPENAI_API_KEY", "") # api key
INPUT_CSV = os.environ.... |
2aa3b735a32b7711b09a3141ae70ee5f13f40732bf29820e18d1d4f655fab792 | Python | 4,233 | 131 | """
Control Spike Sorting Pipeline - Stage 4 (Postprocessing)
=========================================================
Run AFTER stage3_merge.py has produced analyzer_final.zarr for all sessions.
This stage:
1. Creates SessionResponses for each session (responses to stim conditions)
2. Extracts modulation metrics → C... |
ac912495915b9355a6ec3ef10e4de87b95b28d66b1c96afabc05170a8271c597 | Python | 4,233 | 115 | #https://github.com/bendemeo/shannonca
#reduce function accepts a (num genes) x (num cells) matrix X, and outputs a dimensionality-reduced version
from shannonca.dimred import reduce
from scipy.io import mmread
import os
os.chdir('F:/GD/OneDrive/Dokumenter/GitHub/scripts/')
os.getcwd()
X = mmread('Supplementary Table ... |
15321c045ef5953e76cef4d6a988a546b1edfb72f586d462b045216092d027ae | Python | 4,241 | 139 | # Copyright (c) Facebook, Inc. and its affiliates.
import json
import numpy as np
import os
import tempfile
import unittest
import pycocotools.mask as mask_util
from detectron2.data import DatasetCatalog, MetadataCatalog
from detectron2.data.datasets.coco import convert_to_coco_dict, load_coco_json
from detectron2.str... |
acfbfba79a943003d1d40b0c140f2790b17948dcac2f4cb322a43f253d93609e | Python | 4,244 | 75 | import argparse
import torch
from batchgenerators.utilities.file_and_folder_operations import join, load_pickle
from nnunetv2.ensembling.ensemble import ensemble_folders
from nnunetv2.evaluation.find_best_configuration import find_best_configuration, \
dumb_trainer_config_plans_to_trained_models_dict
from nnunetv... |
7a1417936fafe7353ff5e232415f9d198e54a7f2126baefd0ee080892512270b | Python | 4,247 | 129 | import collections
from pathlib import Path
from typing import List
import numpy as np
import tifffile as tif
import torch
from torch.utils.data import DataLoader, Dataset
from sklearn.model_selection import train_test_split
# Assuming transforms.py contains the necessary transformation functions.
from transforms imp... |
45d6ae21c50a4720282fe4cb58660d30d76f9ab2182e16e6709ac9f72f1bea7b | Python | 4,249 | 105 | # Copyright (c) Facebook, Inc. and its affiliates.
import os
import tempfile
import unittest
from collections import OrderedDict
import torch
from iopath.common.file_io import PathHandler, PathManager
from torch import nn
from detectron2.checkpoint import DetectionCheckpointer
from detectron2.checkpoint.c2_model_loadi... |
505426a6ec4cb0869757dd4d28a8ae37828e480f1c0cf565de99b4742963c929 | Python | 4,249 | 120 | """
Meshes
======
<!-- difficulty: beginner -->
Load and save mesh neurons in OBJ, PLY, STL and other formats.
{{ navis }} knows two types of meshes, both subclasses of `trimesh.Trimesh` (and usable as such):
| Class | Use for |
|-------|---------|
| [`navis.Mesh`][] | Neurons stored as meshes, e.g. from EM segmenta... |
c1493bf3ab3522120f3cdc1b618bb14661f8c29184dde6701eba503d496f9e87 | Python | 4,250 | 141 | """Tests for `navis.cast_neuron`.
The function converts the *spatial* data of a neuron to a given dtype. What that
means is per-type, so each neuron class gets its own test. The recurring theme is
the distinction between data and indices: mesh faces, voxel coordinates and
node/parent IDs index into the converted data ... |
bc1f2ce286f33cbc39c8554bb1fd7e86d9c0a9cbe90daa1cb3a04f50da6d8efe | Python | 4,259 | 88 | #python checkIncorporationRate.py F:\promec\HF\Lars\2025\251220_edan\combined\txt peptides.txt "Heavy"
print("peptide.txt output file to calculate the incorporation rate. Distinguish between lysine- and argininecontaining peptides. For each of these subsets determine the incorporation rate as 1–1/average ratio, using t... |
4120b640f7ebb0fdb6fb3ebb05b09cd41e0e52b293e30a866f2b060ea881a213 | Python | 4,261 | 129 | """
Neuron Topology
===============
<!-- difficulty: intermediate -->
Plot neurons as abstract topology graphs using several layout algorithms.
Skeletons in {{ navis }} are hierarchical trees (hence the name [`Skeleton`][navis.Skeleton]).
As such they can be visualized as dendrograms or flat, graph-like plots using [... |
515fa53cf95300c47bfebe3baf474d5b015692037a0d53982d68b6d314d9e950 | Python | 4,263 | 104 | import torch
from torch import nn
class Unet(nn.Module):
"""
Neural network for semantic image segmentation U-Net (PyTorch),
Reference: Falk, T. et al. U-Net: deep learning for cell counting, detection, and morphometry. Nat Methods 16,
67–70 (2019).
Parameters
----------
n_filter : int
... |
ea7c78401c6669cd91074a481d2aaaa59a84a9a7e192a3a7ee5d7e8e70671aaf | Python | 4,279 | 104 | #!../venv/bin/python
import psql_wrapper as psql
def number_of_admissions(cur):
cur.execute('SELECT COUNT(*) FROM admission_targets;')
return cur.fetchone()[0]
def number_of_gender(cur, gender):
cur.execute(('SELECT COUNT(*) FROM admission_targets T\n'
'LEFT JOIN admissions A ON T.hadm_... |
cd58977d970b4fd24b79dc600f22359d5e7da4ab454afa16cd50d735e35e4eff | Python | 4,284 | 116 | """Tram Route Model.
A model of a tram running a multi-station route using continuous-time
kinematics. The tram accelerates to a cruise speed, coasts, brakes at an
analytically-computed point before each station, and dwells before departing
for the next one -- all without the model needing to step on every tick to
che... |
11019b848a9506c78b13784d33db732795bc945ba88bed384b0ed6559b748106 | Python | 4,288 | 140 | import pytest
import torch
from stoic.layers import GATLayer, GCNConv, Identity
torch_geometric = pytest.importorskip("torch_geometric")
def _dummy_gat_layer_class():
class DummyGAT(torch.nn.Module):
def __init__(
self,
in_channels,
out_channels,
heads,
... |
e7ff088859334e55c356abe178822dcbd8e10f43a872e3025c14911d272462b7 | Python | 4,288 | 99 | from copy import deepcopy
from typing import Any, Dict, Optional, Sequence, Tuple
import numpy as np
from brian2 import CodeRunner, Group, NeuronGroup, Synapses, Equations
from ...definitions import NeuronClass, SynapseClass, SynEvent
from ._base import GroupFactory
from . import helper as hp
from .codeblock import C... |
759b395765c52e45a3f9152f676871e36f91847864d90789de85d877c73c32c5 | Python | 4,289 | 109 | # AUTOGENERATED! DO NOT EDIT! File to edit: 02a_parsers_dataset.ipynb (unless otherwise specified).
__all__ = ['GroupedCoverage']
# Cell
import numpy
import scipy
from matplotlib import pyplot
import seaborn
import pandas as pd
import pyfastx
import pyfaidx
from tqdm import tqdm
import pyBigWig
from .utilities import... |
af41f75f783b828f7895309c5fd37402c96adb33e50b5ac0529ab69fcbc9ea35 | Python | 4,296 | 134 | #%% Imports
import pandas as pd
import bambi as bmb
import pymc as pm
import joblib
from pathlib import Path
import numpy as np
import mne
from scipy.stats import zscore
import matplotlib.pyplot as plt
import seaborn as sns
import arviz as az
import matplotlib.patheffects as pe
import sys
sys.path.append('/mnt/obob/st... |
bc6388ae11e34a11b4dd6f50cce659423353276a0dbf7494b899cdac897b3d04 | Python | 4,303 | 158 | """Recompile the bids function stub file based on latest specs."""
from __future__ import annotations
import inspect
import itertools as it
import re
from collections.abc import Iterable
from pathlib import Path
from types import ModuleType
from snakebids.paths import _config, specs
from snakebids.paths._templates i... |
26493164698c0fdc70290900075e54da4c41c73e08b30269745e083aacc0e835 | Python | 4,306 | 118 | # This script is part of navis (http://www.github.com/navis-org/navis).
# Copyright (C) 2018 Philipp Schlegel
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of... |
766c6cc0e7e4917777533df82d07ee5c0a5068352b42826fcc934ccd1d672feb | Python | 4,307 | 108 | # -*- coding: utf-8 -*-
"""
Created on Sat May 7 16:02:01 2022
https://gist.github.com/rachit221195/492768a992fa2f69c0d9769f18291855#file-save_ckp-py
https://gist.github.com/rachit221195/91d5b6e96f5d268af8842235529f88c2#file-load_ckp-py
@author: walte
"""
import torch
import shutil
from glob import glob
im... |
b48ef2eaa82e4b76d350d29814aa7d94cebb01452ef0cffbc524a6e241bfe1c7 | Python | 4,307 | 155 | import torch
from torch import nn
import gym
from gym.spaces import Box
import numpy as np
from collections import deque
from copy import deepcopy
class RacingNet(nn.Module):
def __init__(self, state_dim, action_dim) -> None:
super().__init__()
n_actions = action_dim[0]
print("Action Di... |
9c312e09bd5021a3b64fd960e190a9d60f34e22515832289f608c97b2821d92a | Python | 4,308 | 145 | """configurations for benchmarks."""
from mesa.examples import (
BoidFlockers,
BoltzmannWealth,
MultiLevelAllianceModel,
Schelling,
SugarscapeG1mt,
WolfSheep,
)
from mesa.examples.advanced.alliance_formation.model import AllianceScenario
from mesa.examples.advanced.sugarscape_g1mt.model import ... |
ddffe318d5179a75295134c4336bfb9161dc19e7dcee6707e9d3d61d2a08df76 | Python | 4,309 | 111 | from copy import copy
from pathlib import Path
from typing import Any, Mapping, Optional, Sequence, Type
import numpy as np
from ray import air
from ray import tune
from ray.tune.experiment.trial import Trial
from ray.tune import ResultGrid
from ._base import _overwrite_dir_prompt
from ._searchers import SearchAlg, D... |
9195b1b28c1a255a73d75808c9a1bee83aa1e975b4a670655a4d77582110cb94 | Python | 4,310 | 116 | # -*- coding: utf-8 -*-
"""
Created on Tue Apr 22 15:05:58 2025
@author: Till Habersetzer
Carl von Ossietzky University Oldenburg
till.habersetzer@uol.de
"""
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import colormaps
import os.path as op
#%% Load the CSV... |
209a5016313be35ba27c757f4eaa0a52aad0023e6ae87df0c5509f9ee3999e0d | Python | 4,312 | 39 | #https://pyteomics.readthedocs.io/en/latest/examples/example_fasta.html
#python -m pip install -U pyteomics pandas
#wget https://ftp.uniprot.org/pub/databases/uniprot/current_release/knowledgebase/complete/uniprot_sprot.fasta.gz
#gunzip uniprot_sprot.fasta.gz
#wget https://ftp.uniprot.org/pub/databases/uniprot/curr... |
b7063079768e4e637444dae69c378ee741d2ca4ec7cfe52b9762b7416ae10e2e | Python | 4,315 | 129 | """
Run v3 pipeline on all experimental animals and ICMS83 with specified window configs.
Usage:
# 700ms on all animals
python -m batch_process.postprocessing.responses_v3.run_all_animals --window 700ms
# 150ms on all animals
python -m batch_process.postprocessing.responses_v3.run_all_animals --window... |
b977b1ba1dd9513d4db28a3a3daa8c941d7453ef7de442f1b724a3456bfb1274 | Python | 4,315 | 160 | import numpy as np
import matplotlib
from matplotlib.axes import Axes
def plot_xy_range(
ax, xy_range, linestyle="--", color="k", linewidth=1, label=None, zorder=1
):
"""
xy_range : ((x_min, x_max), (y_min, y_max))
"""
assert (
len(xy_range) == 2 or len(xy_range) == 4
), "xy_range shou... |
18965f957c46522967331165999ad7120da91a3cacc6bf25e7c8403171209059 | Python | 4,316 | 129 | #
# Copyright (c) 2024 10X Genomics, Inc. All rights reserved.
#
"""Functions and constants for all post processing of CAS."""
import csv
import json
from pathlib import Path
# Key in cell annotation out
SCORE_KEY = "score"
CELL_TYPES_ID_KEY_IN = "cell_type_ontology_term_id"
MATCHES_KEY_IN = "matches"
# Key in conso... |
ca9025b3a1292790a170d4c1bd889d78a9b51a50df6a4f7d693b660a11a66edd | Python | 4,324 | 133 | from abc import abstractmethod
import torch
from torch import Tensor, nn
from chemprop.nn.hparams import HasHParams
from chemprop.utils import ClassRegistry
__all__ = [
"Aggregation",
"AggregationRegistry",
"MeanAggregation",
"SumAggregation",
"NormAggregation",
"AttentiveAggregation",
]
cl... |
b4c493217bceba4f76ad4a9757816230a41c6169dcb93332c9ec1542ff6ebd4a | Python | 4,328 | 134 | from pathlib import Path
import numpy as np
import mesa
from mesa.discrete_space import OrthogonalVonNeumannGrid
from mesa.examples.advanced.sugarscape_g1mt.agents import Trader
from mesa.experimental.scenarios import Scenario
# Helper Functions
def flatten(list_of_lists):
"""
helper function for model data... |
f002d360c7234f1de5724eb4897bc29310b9e802c2c5fc56a8b4b1576823c6b6 | Python | 4,328 | 135 | from __future__ import annotations
import argparse
import json
from pathlib import Path
from typing import Any
import pytest
from hypothesis import given
from pytest_mock import MockerFixture
from snakebids import bidsapp
from snakebids.app import SnakeBidsApp, sb_plugins
from snakebids.cli import add_dynamic_args
f... |
1b29d5779d24395789a85ae126311f1c68eddcc16a2fe37bdc7981649c58ac2f | Python | 4,342 | 98 | import numpy as np
import dgl
from Metapath_Augmentation import learner
from Metapath_Augmentation import simulator
from scipy import sparse
import itertools
import random
import torch
torch.manual_seed(123)
random.seed(123)
# Metapath (graphon-based) augmentation of the drug/disease heterogeneous graph
class Path_Au... |
ea1c22f5018900c929843918c3e6cde7d7fb2c90511fb0703e26b9106926095a | Python | 4,343 | 116 | # Copyright (c) Facebook, Inc. and its affiliates.
from detectron2.layers import batched_nms
from detectron2.modeling import ROI_HEADS_REGISTRY, StandardROIHeads
from detectron2.modeling.roi_heads.roi_heads import Res5ROIHeads
from detectron2.structures import Instances
def merge_branch_instances(instances, num_branc... |
5eece23b73dbdeecd05e51bad8e394337a824c73e0f131f4170ad2f2b3ad3bcb | Python | 4,344 | 124 | from pathlib import Path
import yaml
import argparse
import numpy as np
import torch
import torchvision.transforms as transforms
import torchvision.utils
from . import config
from .utils.decomposition_handler import DecompositionHandler
from .utils.ica import ICAHandler
from .utils.data_utils import prepare_data
from... |
12d5d7ce18fafa0090f2cc1ed9f0a565f6dd831ad288c944c04a09c87ba38e8e | Python | 4,345 | 90 | # -*- coding: utf-8 -*-
"""
Batch Processing of Physio Files
This script can be used to loop over the script "CreatePhysioPredictors_BIDS.py" and create the physiological
regressors for multiple functional runs at the same time.
Please note: To date this script works only if the pulse and respiratory data are not saved... |
97b886930108882e5cd6871a2d0bf7e0f900c5b971b98147243cb79106ff0c02 | Python | 4,346 | 96 | from __future__ import annotations
from collections.abc import Sequence
import numpy as np
import pandas as pd
def base_feature_name(feature_name: str, base_variables: Sequence[str] | None = None) -> str:
if base_variables:
for variable in sorted(base_variables, key=len, reverse=True):
if fe... |
494d884be9be02caf59cee0cb0568c08198be14058a0ad18d6973092daf47af8 | Python | 4,351 | 116 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) Facebook, Inc. and its affiliates.
import functools
import json
import multiprocessing as mp
import numpy as np
import os
import time
from fvcore.common.download import download
from panopticapi.utils import rgb2id
from PIL import Image
from detectron2.da... |
a4abba6ed60c45e8953ae818a1a105503679c1014f94d937fb291884f280c3c4 | Python | 4,352 | 136 | """Script to generate a Snakebids project."""
import argparse
import re
import sys
from pathlib import Path
import copier
import more_itertools as itx
from colorama import Fore, Style
import snakebids
from snakebids.utils.utils import text_fold
def create_app(args: argparse.Namespace) -> None:
"""Implement the... |
ea5162908f4dbc4a0160ce3cf2ed58be9c6442317579287e424a30e8d6bb9015 | Python | 4,355 | 109 | #%%
from pathlib import Path
import sys
sys.path.append('/mnt/obob/staff/fschmidt/cardiac_1_f')
import pandas as pd
import joblib
import numpy as np
from plus_slurm import Job
#%%
class SlopesAcross(Job):
#%% the run method starts here
def run(self, cur_channel, sss):
heart_thresh, eye_thresh = 0.4... |
e4b18e0e0734d8565da77f2ae8ae49a4cc63ec366efc019bfc4798b6a196877e | Python | 4,362 | 146 | import numpy as np
import scipy
import nibabel as nib
import matplotlib.pyplot as plt
from scipy.spatial import Delaunay
import matplotlib
matplotlib.use('Agg')
from scipy.interpolate import RegularGridInterpolator
# this script creates a mesh with triangulation density locally-adaptive based on an average surface ar... |
836810ec0852436acb8ee6a4c6b397f34c33cd377fb5c6f5181fd3b2b8b34289 | Python | 4,367 | 142 | """This integration test is designed to ensure that the chemprop model can _overfit_ the training
data. A small enough dataset should be memorizable by even a moderately sized model, so this test
should generally pass."""
import sys
from lightning import pytorch as pl
import pytest
import torch
from torch.utils.data ... |
d0959693ab303f5214e8a5bb6e3594600a0ac34337ed44e3e883aed4eb3e9ccd | Python | 4,367 | 137 | """
VAE-based molecular generation.
Provides functions for generating novel molecules by sampling from a trained
VAE latent space and saving results to disk.
"""
import logging
from pathlib import Path
from typing import Any, Dict, List, Optional
import pandas as pd
import torch
from nfml.generate.mol_db import ded... |
ff2210c5b9e637e7286eadf086efd69c56346ef21e6af0c87a20f83a6ce539ab | Python | 4,370 | 161 | # This script is part of navis (http://www.github.com/navis-org/navis).
# Copyright (C) 2018 Philipp Schlegel
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of... |
969faa9f020cafc92c3165bc3568e39702b6af7578e053f290df172747cfa450 | Python | 4,374 | 136 | #!/usr/bin/env python
# Copyright 2016-2020 Biomedical Imaging Group Rotterdam, Departments of
# Medical Informatics and Radiology, Erasmus MC, Rotterdam, The Netherlands
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obt... |
8befd5ea46123b077ead6b4dcacfe36a934b6b68169b37ecd7fd4dd87581fb66 | Python | 4,375 | 130 | from typing import Sequence
import numpy as np
from rdkit.Chem.rdchem import Bond, BondType
from chemprop.featurizers.base import VectorFeaturizer
class MultiHotBondFeaturizer(VectorFeaturizer[Bond]):
"""A :class:`MultiHotBondFeaturizer` feauturizes bonds based on the following attributes:
* ``null``-ity (... |
326a614324d46c7cab970a87a214f090da0ca9c16deb0630743a92e25cbf7c0c | Python | 4,381 | 112 | import pytest
from typing import Optional, Dict, Any
from hsnn.utils.io import formatted_name
class TestFormattedName:
"""Tests for the formatted_name function.
"""
@pytest.mark.parametrize(
"base_name, ext, expected",
[
("file", None, "file"),
("file", "txt", "fi... |
6dec72fbd5e51a0f0de5e27b366f96b653ba634358d533899d37de68876473d7 | Python | 4,384 | 82 | import argparse
from typing import Union
from batchgenerators.utilities.file_and_folder_operations import join, isdir, isfile, load_json, save_json
from nnunetv2.imageio.reader_writer_registry import determine_reader_writer_from_dataset_json
from nnunetv2.paths import nnUNet_preprocessed, nnUNet_raw
from nnunetv2.uti... |
97641529e6559c4e8795ea383573c3581788d1cbdf9c93dff92bb4c710ed13ee | Python | 4,386 | 150 | import sys
from pathlib import Path
import click
import click_log
from .._env import run_captured, use_ilastik_env
from .._steinbock import SteinbockException
from .._steinbock import logger as steinbock_logger
from .utils import OrderedClickGroup, catch_exception
@click.group(name="apps", cls=OrderedClickGroup, he... |
46da1e1dde372d1e3f56854990996beb7250d1d7069f583145d93e592e7983c3 | Python | 4,393 | 136 | """Mirror script output to a log file during standalone execution."""
import atexit
import os
import shlex
import sys
from pathlib import Path
DISABLE_LOG_ENV = "AIDAMRI_DISABLE_SCRIPT_LOG"
GIT_INFO_FILENAME = "AIDAmri_git_information.txt"
BUILD_GIT_INFO_PATH = Path("/aida/build") / GIT_INFO_FILENAME
_LOG_FILES = []... |
42083943fc88891ec657ef241f678788f1f2e60100f887b87607101888874174 | Python | 4,395 | 130 | from unittest import mock
import click
import pytest
from click.testing import CliRunner
from openfe.setup import LigandAtomMapping, LomapAtomMapper
from openfecli.commands.atommapping import (
atommapping,
atommapping_print_dict_main,
atommapping_visualize_main,
generate_mapping,
)
from openfecli.par... |
10d91c36f87d0eb59980f80415702ede884cc52f188a24f72c5e8f981cbbb451 | Python | 4,400 | 152 | from typing import Iterable, Optional, Sequence, cast
import pandas as pd
from sqlalchemy import and_, or_, select
from hsnn.core.logger import get_logger
from hsnn.utils.handler import TrialView
from ..base import PNG
from ..refinery import Constrained, Match
from . import _utils
from .database import PNGDatabase
f... |
90c5191baeefe36a733d18a5b9a6dc5f9ca968e603042cd2073a0fd3170b3c99 | Python | 4,420 | 96 | # Copyright (c) Facebook, Inc. and its affiliates.
# pyre-unsafe
from typing import List
import torch
from detectron2.config import CfgNode
from detectron2.structures import Instances
from detectron2.structures.boxes import matched_pairwise_iou
class DensePoseDataFilter:
def __init__(self, cfg: CfgNode):
... |
f72178e107006237b052f94a55d1657198b9c071e7d83dfc97f8b3bb7da707ae | Python | 4,420 | 138 | import logging
from enum import Enum
from functools import partial
from importlib.util import find_spec
from os import PathLike
from pathlib import Path
from typing import (
TYPE_CHECKING,
Any,
Generator,
Mapping,
Optional,
Protocol,
Sequence,
Tuple,
Union,
)
import numpy as np
fro... |
33ad9eacf541a45748337780a39fbe251e424d9ea7fd6dff26ab21d065ebb37a | Python | 4,421 | 107 | import pandas as pd
import numpy as np
# Download and load data (keeping your original download code)
url = "https://server-server-drive.promec.sigma2.no/Data/report.parquet?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=promecshare%2F20250821%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250821T110621Z&X-Amz-Expire... |
d4ca872f610ae577c1e0a4bb6b5dc9e7a41179f144f6e0ecef1f1c82eec6ffd3 | Python | 4,430 | 131 | """Atom-graph featuriser for MolGpKa.
Vendored from MolGpKa (https://github.com/Xundrug/MolGpKa), MIT License.
Patched for SMILES2Docking: package-relative import only.
"""
from rdkit import Chem
from rdkit.Chem import AllChem
from rdkit import RDLogger
RDLogger.DisableLog("rdApp.*")
from rdkit.Chem import rdmolops
... |
2be187cb3d245340273f26bb87426c3079290ddea0adef2eb121b981c09af1df | Python | 4,433 | 147 | import numpy as np
import scipy
from toolbox.comparison import complex_corr
def fisherZ(R2):
'''
Return the Fisher zscore of a correlation coefficient. Allows to get a
uniform distribution
Parameters
----------
R2 : FLOAT or ARRAY
Coefficient correlation
Returns
... |
4f6c4e102e26e697b64792d2812393cc7c2ab5cf2f11f99849e4e51f0cbefe9a | Python | 4,434 | 142 | from pathlib import Path
import click
import click_log
import numpy as np
import pandas as pd
from ... import io
from ..._cli.utils import OrderedClickGroup, catch_exception, logger
from ..._steinbock import SteinbockException
from ..._steinbock import logger as steinbock_logger
from .. import external
@click.group... |
f02df5805b1ba87950258293dce398b4214905674be6521d4f79f5b29346f3f6 | Python | 4,437 | 143 | """ Created on Thu Nov 14 2025
@author: dcupolillo """
import torch
import numpy as np
from torch.utils.data import Dataset
import matplotlib.pyplot as plt
class DffDataset(Dataset):
"""
Dataset class for dF/F calcium imaging data only.
This class handles loading and augmenting the dFF data.
"""
... |
30d499189f2a0d0134c69a38ff2236471698235b74a8c60894fd2c03aed3ce55 | Python | 4,438 | 126 | import pickle
import numpy as np
import os
from scipy.interpolate import interp1d
from matplotlib import pyplot as plt
from rCPGswCPG.Network import firing_rate
from rCPGswCPG.Network import construct_model
from rCPGswCPG.model_params.config_loader import load_model_cfg_file, model_params_from_cfg
from rCPGswCPG.utils.... |
744ce35c070e6176ac74eb64c0f065ecebf246cf0331c0b88657f3590fc5f1b2 | Python | 4,439 | 142 | import os
import numpy as np
from scipy.stats import norm
from statsmodels.stats.multitest import multipletests
import warnings
def run_kbet(df, do_PCA=False):
"""
Run kBET analysis using R from Python.
Parameters:
df (pd.DataFrame): Input dataframe with a 'condition' column and columns c... |
64ce64a6a677e7d786c9ab87dc734608ebb676307cbaabb4281f9ebb955931d5 | Python | 4,443 | 109 | #!/usr/bin/env python
# Copyright 2016-2019 Biomedical Imaging Group Rotterdam, Departments of
# Medical Informatics and Radiology, Erasmus MC, Rotterdam, The Netherlands
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obt... |
1aafeacef21cf4b708ec9c9d02186422b30f55521399498f29325ca969439f45 | Python | 4,455 | 85 | # the extraction of the PRC from the recording obtained on a simplified model (simplified neurons) of interaction
# between the recpiratory and the swallowing CPG.
from copy import deepcopy
import numpy as np
from matplotlib import pyplot as plt
from tqdm.auto import tqdm
from rCPGswCPG.prc_extraction.prc_extraction_su... |
26464e0916f7acbe68592a48ccf6bf772aa20b965c12e2ba8e6fd176a87c3b12 | Python | 4,456 | 116 | # Copyright (c) Facebook, Inc. and its affiliates.
import copy
import logging
import numpy as np
from typing import Callable, List, Union
import torch
from panopticapi.utils import rgb2id
from detectron2.config import configurable
from detectron2.data import MetadataCatalog
from detectron2.data import detection_utils ... |
e00e940cee8eb8bf7f9fc175b9fad4c285889b6a363b67e33cea9bc4b802c469 | Python | 4,472 | 119 | import os
import numpy as np
import nibabel as nib
import matplotlib.pyplot as plt
from tristan_pipeline.utils.plotting_utils import *
from tristan_pipeline.utils.analysis_utils import *
from tristan_pipeline.io.params import *
from nilearn import surface, plotting
import nibabel.freesurfer as fs
from mpl_toolkits.mplo... |
c711e5837612036ec3eb61c7e2523c5f177c3424f310d41c1b63929c975e41ca | Python | 4,476 | 118 | #!/usr/bin/env python3
"""
Example script for contrast-agnostic registration using SynthSeg
This script demonstrates a full registration pipeline that uses SynthSeg's brain
parcellation to enable registration between images of different contrasts:
1. Generate parcellations of both input and reference images using Sy... |
ee1067dd0dbf30c4c78bc3a165917ecfe1b4cc04e41a332d8e3e63f91f8eda8d | Python | 4,476 | 140 | import torch
import torch.nn as nn
import torch.nn.functional as F
from torchvision import transforms
import math
from scipy.fftpack import dct
from .meta.electrode_names import channels
from .VisualTransforms import EEGScalpMap
# Hyperparameters
num_classes = 10
image_size = 20
patch_size = 6
projection_dim = 64
dct_... |
2f5eded8b3fcbff509e5812ed36fe3b854acffbfe6ccb0e40951cd93084db8bc | Python | 4,481 | 138 | from composer import Callback
from pathlib import Path
import torch
from torch import Tensor
import torch.nn as nn
import torch.nn.functional as F
from torchmetrics import Metric
from typing import Optional
class CosineDistanceLoss(nn.Module):
def __init__(self):
super().__init__()
def forward(
... |
aadf47e585140b3c69462eebe3a8c934a42b0139f184e2fda79f8ff4d8a398f0 | Python | 4,481 | 125 | import logging
import re
from os import PathLike
from pathlib import Path
from typing import Dict, Generator, List, NamedTuple, Sequence, Tuple, Union
import numpy as np
from skimage import measure
from .. import io
from ._utils import SteinbockUtilsException
logger = logging.getLogger(__name__)
class SteinbockMos... |
7253b4e4ce4b037d0bdb7733e56380ec4ecf49a27b4083120cbce6b26d84525a | Python | 4,485 | 126 | #!/usr/bin/env python
#
# Copyright (c) 2024 10X Genomics, Inc. All rights reserved.
#
"""Append celltypes to an existing cloupe file."""
import subprocess
from dataclasses import dataclass
import martian
import cellranger.cr_io as cr_io
import tenkit.log_subprocess as tk_subproc
__MRO__ = """
struct CellAnnotati... |
ebd4014fb31c28ede31f768ab173cd99476adb64290b71cd6d976a0ceb026db3 | Python | 4,487 | 102 | #https://github.com/google/jax#installation
from jax import grad
import jax.numpy as jnp
def tanh(x): # Define a function
y = jnp.exp(-2.0 * x)
return (1.0 - y) / (1.0 + y)
grad_tanh = grad(tanh) # Obtain its gradient function
print(grad_tanh(1.0)) # Evaluate it at x = 1.0
# prints 0.4199743
#https://jax.readth... |
20559862d64c1abe3a3e1609257d95fc543b8cf3a9fa5d4769280e99fbaf059e | Python | 4,490 | 132 | from __future__ import annotations
from abc import ABC, abstractmethod
from typing import Any, Dict, Iterable, Optional, Sequence, Type
import numpy as np
import pandas as pd
from hsnn.core.definitions import Projection
from hsnn.simulation import Simulator
from ._utils import get_rates_db
scalar_registry: Dict[str... |
4b11a46ecdd544c22089db92a342de99cfaf72d4ebd9a168dc6671460b55cb19 | Python | 4,492 | 164 | #!/usr/bin/env python
#
# Copyright (c) 2018 10X Genomics, Inc. All rights reserved.
#
"""Functions for fast, memory-efficient operations on masked sparse matrices."""
from __future__ import annotations
from typing import overload
import numpy as np
@overload
def sum_masked(
matrix,
row_mask: np.ndarray[... |
1a16e6a7d5dba9905846b6bf6ad907f5f5b02c9b238a12924e641108601e4d3a | Python | 4,493 | 115 | import torch
from torchmetrics import Accuracy, MeanMetric, MetricCollection
from torchmetrics.classification import ConfusionMatrix
import lightning as L
class LightningModel(L.LightningModule):
def __init__(self, model, cfg, class_weights):
super().__init__()
self.cfg = cfg
self.model = m... |
6e7d04d02dbf0c85c3e26c56a13847af03116a83e471a61579b5641c3868a89c | Python | 4,495 | 137 | #!/usr/bin/env python
#
# Copyright (c) 2017 10x Genomics, Inc. All rights reserved.
#
from __future__ import annotations
import copy
import json
from collections import OrderedDict
from typing import TYPE_CHECKING
import martian
import cellranger.constants as cr_constants
import cellranger.rna.library as rna_libr... |
0d6368deae5e6fd761e1e7c7c19efbb369c152672c157a8b14d5451025f22439 | Python | 4,496 | 149 | """
An example config file to train a ImageNet classifier with detectron2.
Model and dataloader both come from torchvision.
This shows how to use detectron2 as a general engine for any new models and tasks.
To run, use the following command:
python tools/lazyconfig_train_net.py --config-file configs/Misc/torchvision_... |
db8908280cabd14cdfd08b472fd62a3250beba82c8910d46a889760cbfb65daa | Python | 4,497 | 129 | from __future__ import division
from ldscore import parse as ps
import unittest
import numpy as np
import pandas as pd
import nose
import os
from nose.tools import *
from numpy.testing import assert_array_equal, assert_array_almost_equal
DIR = os.path.dirname(__file__)
def test_series_eq():
x = pd.Series([1, 2, ... |
389c789cf6174666ffc919a4431a4f6ac92c70ef9d45c1b486d0b90ddac70ca6 | Python | 4,499 | 164 | # -*- coding: utf-8 -*-
"""For reading and writing CARET files."""
from io import BytesIO
import re
import struct
import nibabel as nib
import numpy as np
def read_surface_shape(fn):
"""
Read surface_shape CARET file.
Parameters
----------
fn : str
Filepath to surface_shape file
Re... |
72e78a49b9a6f32f5ebc0a8312804ee49ecbd228b4e8b9537348b847dfe6fa15 | Python | 4,501 | 111 | from typing import Tuple, Union, List
from batchgenerators.utilities.file_and_folder_operations import save_json, join
def generate_dataset_json(output_folder: str,
channel_names: dict,
labels: dict,
num_training_cases: int,
... |
ce3138250a457be2c4ed52a7223cd0b6fb94d0acab4076facaddb61cfe6a3ef5 | Python | 4,503 | 133 | from __future__ import annotations
import sys
from copy import deepcopy
from pathlib import Path
from typing import Any
import yaml
from src.utils.app_paths import (
is_appimage,
is_frozen,
user_cache_dir,
user_data_dir,
user_log_dir,
)
PROJECT_ROOT = Path(__file__).resolve().parents[2]
DEFAULT... |
7bb449f58d0313b5d605ac8f73401f585cab4141bebb4fe6095afee37f3b63b1 | Python | 4,506 | 123 | import argparse
import math
import importlib
import os
import rootutils
import torch
from lightning import Trainer, seed_everything
from lightning.pytorch import callbacks
import sys
from src.common.utils import parse_module_name_from_path # noqa: E402
from src.models import GruVAE # noqa: E402
from src.dataio.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.