sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
0372ab46dd7cd77f7449034f3fd420440f8f4d2541c592f071e2fce8b6b920c3 | Python | 10,801 | 338 | """
Analyzing Neuron Morphology
===========================
<!-- difficulty: intermediate -->
Measure morphometrics — segment lengths, geodesic distances and branch angles.
Disclaimer: As you might imagine some properties can be gathered for all/most neuron types while others will only work
on specific types. For exa... |
58c1d3e0993f78c4f81c7e59fd35c79f2cad8d6a0bc2fd4c16b19391b05e3c0a | Python | 10,807 | 281 |
'''This file contains the plotting functios that can be used when testing the estimators with real MEG data'''
# General imports
import numpy as np
import matplotlib
from matplotlib import gridspec
import matplotlib.pyplot as plt
import mne
# Imports from our library
from micorr.realdata import ch_locs, test_est
fr... |
1a509182183f5fbde26a0ecffc0dd0ad60370a0ff3a431bab687ebf1f8e27a05 | Python | 10,819 | 311 | """ Making datasets accessible
The file contains one base class for all datasets and a separate subclass for
each used dataset.
"""
__author__ = "Fabi Bongratz"
__email__ = "fabi.bongratz@gmail.com"
import os
import torchio as tio
import numpy as np
import torch
import torch.nn.functional as F
import nibabel as nib
... |
2d3965505dae781e1161ad20f0d696e8b7c4bf60668b1b654b64f21132126c43 | Python | 10,821 | 267 | import os
import shutil
from pathlib import Path
from typing import Tuple, List
import numpy as np
import tifffile
import torch
from albumentations import (ShiftScaleRotate, GaussNoise, ShotNoise, RandomCrop3D, RandomBrightnessContrast, Compose,
Blur)
from torch.utils.data import Dataset
... |
83827f3eca8b7fd5ed0969409685955db7fdc4c4dc9c93db6022e602aa5f6ce5 | Python | 10,824 | 285 | """
Module: models.py
Description:
- Implements a variety of regression models including MLP, CNN, RNN variants,
Transformer, and placeholders for DNA-BERT2 / RNA-FM fine-tuning heads.
"""
import torch
import torch.nn as nn
from config import SEQ_LENGTH, FEATURE_DIM, OUTPUT_SIZE, ENCODING_DIMS
class MLPRegress... |
34b00bde5d6935e23279aca712bf67ea42ace3069445db533f5b0e7762cf978e | Python | 10,840 | 223 | ############################################################################
# Copyright (c) 2022-2026 University of Helsinki
# Copyright (c) 2020-2022 Saint Petersburg State University
# # All Rights Reserved
# See file LICENSE for details.
############################################################################
... |
9efa5a51e0c5a24c09479180849b0863eb51265b4d8fbc51edde2de7f966fd65 | Python | 10,841 | 354 | from composer import algorithms
from composer.core import DataSpec
from composer.models import HuggingFaceModel, ComposerModel
from composer.callbacks import (
LRMonitor,
RuntimeEstimator,
)
from composer.loggers import TensorboardLogger, FileLogger
from composer.optim import DecoupledAdamW
from composer.optim.... |
df9aea9579e9dafcdaa8e07aa0ae34fa02296e156e05ef8bcea8ad2e49af6c42 | Python | 10,847 | 250 | """
06_velocity_off_manifold_mod.py
訓練済み DREG_DYN モデルから latent dynamics の on/off-manifold 不確実性を
modality 空間で定量し、結果を loom ファイルおよび UMAP プロットとして保存する。
velocity_off_manifold.py (latent 空間での分解) との違い:
- 局所接線空間を latent 空間ではなく各 modality の低次元埋め込みで推定する
(RNA: PCA, ATAC: TruncatedSVD/LSI)
- velocity サンプルを各 modality の低次元空間... |
0fe1fdd51439a6748319c8991718ac468f5a7ecef767f6c8420bd571398dfadc | Python | 10,849 | 209 | # Copyright (c) Facebook, Inc. and its affiliates.
# pyre-unsafe
import copy
import numpy as np
import torch
from fvcore.transforms import HFlipTransform, TransformList
from torch.nn import functional as F
from detectron2.data.transforms import RandomRotation, RotationTransform, apply_transform_gens
from detectron2.m... |
4bc623890593d764a48c4e68df20516fa425f194eaad69fc6a879f6603bf5341 | Python | 10,856 | 300 | # -*- coding: utf-8 -*-
# Copyright (c) Facebook, Inc. and its affiliates.
import logging
import numpy as np
import os
import tempfile
import xml.etree.ElementTree as ET
from collections import OrderedDict, defaultdict
from functools import lru_cache
import torch
from detectron2.data import MetadataCatalog
from detec... |
6417eeef90e1d653375c5906ed5518ade1e5a732072a983a71aaac015c5fbc0e | Python | 10,863 | 256 | # Copyright (c) Facebook, Inc. and its affiliates.
import io
import tempfile
import unittest
from contextlib import ExitStack
import torch
import torch.distributed as dist
import torch.multiprocessing as mp
from detectron2.utils import comm
from densepose.evaluation.tensor_storage import (
SingleProcessFileTenso... |
1e1f0ceb52fe1597df28a689654929eccfbef5dc9812ef7796d4b70e87f0ee82 | Python | 10,864 | 357 | """Train and validation step functions for GNN and VAE models.
Provides single-epoch train/validation steps that are composed by the
higher-level k-fold functions in ``nfml.train.kfold``.
"""
import logging
from typing import Callable, Dict, Optional, Tuple, Union
import numpy as np
import torch
import torch.nn as nn... |
e654dccf464f61af751f2159a9b49f0084b883def7bb9b7f6b7d347d72160f1f | Python | 10,869 | 275 | # Copyright (c) Facebook, Inc. and its affiliates.
import numpy as np
from typing import Tuple
import torch
from PIL import Image
from torch.nn import functional as F
__all__ = ["paste_masks_in_image"]
BYTES_PER_FLOAT = 4
# TODO: This memory limit may be too much or too little. It would be better to
# determine it b... |
f5daecf52550e140460fc93ab682283dc0e46b14ad28b9411070fd1a76137bff | Python | 10,869 | 273 | # Copyright (c) Facebook, Inc. and its affiliates.
import itertools
import logging
import numpy as np
from collections import OrderedDict
from collections.abc import Mapping
from typing import Dict, List, Optional, Tuple, Union
import torch
from omegaconf import DictConfig, OmegaConf
from torch import Tensor, nn
from ... |
17dfff335b50f309f4a35bcfc5c97cf0e75b2365002e68155f5940a025205938 | Python | 10,878 | 361 | # This code is part of OpenFE and is licensed under the MIT license.
# For details, see https://github.com/OpenFreeEnergy/openfe
import warnings
from typing import Optional, Union
import matplotlib.pyplot as plt
import numpy as np
import numpy.typing as npt
from matplotlib.axes import Axes
from openff.units import Qua... |
8343085ac692dc6922f9a30bf75f321b26720e8ad3300b7edddf85f8e0d1342c | Python | 10,879 | 270 | # Run Garnet training simulations
# Change non-bonded 1-4 scaling (NonbondedForce line) in
# /path/to/miniconda3/envs/openmm/lib/python3.11/site-packages/openmmforcefields/ffxml/amber/gaff/ffxml/gaff-2.11.xml
# to match TIP3P force field file value (0.833333)
# Change chem_shift_path to point to the nmr conda envir... |
37a08beafd98ec65a5eed0312b564c541e853f3ff036fb63d5cf54a878e9e6ff | Python | 10,886 | 331 | #!/usr/bin/env python
#
# Copyright (c) 2017 10X Genomics, Inc. All rights reserved.
#
"""Louvain graph clustering interface."""
from __future__ import annotations
import errno
import os
import pickle as cPickle
import subprocess
import time
from collections.abc import Iterable
import h5py
import numpy as np
import s... |
330d74b79913202a06c6ce3ad5ad3dc12fe92b438bad0b15334e8a1f87348efd | Python | 10,887 | 317 | #!/usr/bin/env python
from collections import OrderedDict, MutableMapping
import re
class ElastixParameterFile(MutableMapping):
"""
ElastixParameterFile is a dictionary object to allow access to parameter file in a style like::
>>> params = ElastixParameterFile('/path/to/file/params.txt')
>>> params[... |
938046a716b7f9caeb1990bb671416ef4b122bbd796e3ce02247a0d9090714fb | Python | 10,891 | 302 | #!/usr/bin/env python
"""Train a VAE on the NF database, or sample molecules from a trained one.
Training and sampling are two subcommands of one entry point because they
need exactly the same featurisation. Splitting them across separate scripts
lets the two drift apart, which produces silent shape mismatches rather ... |
55ea1ee1e00a87816a18263047c9cd56cd140e7a76afd86847f108e8ba48106e | Python | 10,894 | 286 | import os
import sys
from itertools import combinations
from typing import Sequence
import numpy as np
import numpy.typing as npt
import pandas as pd
from .base import PNG
from hsnn import ops
class PrintManager:
def __init__(self, verbose: bool = False) -> None:
self._verbose = verbose
def __enter... |
83ff83f665ad3397cff5db87f82c739626e7e551e95eb99ac8ed5b13a17b9d50 | Python | 10,901 | 310 | #!/usr/bin/env python
# Copyright 2020 - 2021 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 o... |
3086330c774355809af6c4ce02220a01811187a01a7d0be5cc914c4ac07e4a48 | Python | 10,908 | 203 | """SAMPLING ONLY."""
import torch
import numpy as np
from tqdm import tqdm
from functools import partial
from ldm.modules.diffusionmodules.util import make_ddim_sampling_parameters, make_ddim_timesteps, noise_like
class DDIMSampler(object):
def __init__(self, model, schedule="linear", **kwargs):
super()... |
c2d6e0e446e32d29144076ef4128c2815b46fbc4e5ac5fb4542b1bd8256c3540 | Python | 10,924 | 314 | #!/usr/bin/env python
#
# Copyright (c) 2014 10X Genomics, Inc. All rights reserved.
#
"""Helper for functions for logging calls to subprocesses.
In addition to logging, these wrappers will also (on linux) set PDEATHSIG on
the child process, so that they are killed if the parent process dies.
"""
from __future__ imp... |
df928517b28d61a0b3f5d1366f2fa36499c1cf750408af1dec280403142dd4c0 | Python | 10,932 | 314 | """Tests for the psyp70385 MCP server tools.
Every expected number here comes from the published paper itself
(Leimroth et al. 2026, doi:10.1111/psyp.70385), section 4.2 and the PRISMA
flow diagram (Figure 1), or from Tables 1-7 directly. Run with:
uv run pytest tests/test_tools.py -v
"""
import sys
from pathlib ... |
7a8aaf75e187e0711ea496cc3a6c4de7a9fcde3bf19cd368fd49616a13eec0f5 | Python | 10,934 | 293 | """Tests for `navis.nbl.extract_matches`.
Unlike the graph primitives, this genuinely *does* have two live code paths:
`_fastcore_matrix` hands fastcore the score matrix only when its buffer is a
float16/32/64 and contiguous, and falls back to numpy otherwise rather than
copying what may be tens of GB. Both paths ship... |
002e300e143736fe080d9b3894b49ae667b8a4b9476d8e2426f985e72b21068e | Python | 10,958 | 311 | """Track files created by AIDAmri processing stages.
The tracker takes a recursive snapshot of one modality directory when a stage
starts and updates a dataset-local JSON manifest when the Python process exits.
Only newly created paths are considered owned outputs. Existing files that were
modified are recorded for pr... |
80af01e49f42934d5efaa8d22fb8fd826ffdb1a912c225094072231ab858b1d1 | Python | 10,958 | 299 | import pickle
from pathlib import Path
import matplotlib
import matplotlib as mpl
import os.path
from bio_image_unet import unet # pip install bio-image-unet
import numpy as np
import matplotlib.pyplot as plt
import tifffile
from matplotlib.ticker import MultipleLocator, FormatStrFormatter
from matplotlib_scalebar.... |
9e7ea20c3c49837f58cffb4fe8fd09f9ab3889ef93fe0357c3439ce9e91ca2a7 | Python | 10,960 | 287 | import os
import glob
import time
from collections import defaultdict
from typing import List, Dict
import json
import pandas as pd
import PyPDF2
import docx
from pptx import Presentation
from PIL import Image
import pytesseract
from dotenv import load_dotenv
from openai import OpenAI
load_dotenv(override=False)
DE... |
5d22b0afa75dd0fb9323d8ef903da21229116b12a15174791c901f6ef7249f2d | Python | 10,968 | 235 | """様々な自作関数をおいておくファイル"""
import numpy as np
import matplotlib.pyplot as plt
from scipy import signal
from scipy import interpolate
from matplotlib.colors import LinearSegmentedColormap
import win32com.client
import matplotlib.animation as animation
def myFFT(data, fs):
"""フーリエ変換する関数
data: 時系列データ
fs: サンプリング周... |
8c1699c45cdf47c450b62e90fa51687ba0ab42622ac67e6fe0668860d9e9f605 | Python | 11,013 | 306 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
sphinx-autopackage-script
This script parses a directory tree looking for python modules and packages and
creates ReST files appropriately to create code documentation with Sphinx.
It also creates a modules index (named modules.<suffix>).
"""
# Copyright 2008 Société ... |
013b8791ded877262d3a4a857441c34b224260e6807ba63ef6a1bc93dd6f1854 | Python | 11,019 | 292 | """Tests for `navis.utils.meshproc` - our stand-in for trimesh's `process=True`.
The contract is not "produces a sensible mesh" but "produces *exactly* what
trimesh produces": same vertices, same faces, same order. Anything less would
renumber vertices, and a vertex index is what connectors, extra edges and the
skelet... |
c484680a7bf8a26c6e907e86f3e34f2026ed43511da6536e2050a80b6101de7c | Python | 11,020 | 267 | """Numerical parity against the published NF results.
The port's central claim is that it changed no numerics. These tests prove it
by **replay**: every published run saved its held-out test SMILES alongside the
raw per-member predictions, so the ported code can be run over the same inputs
and compared against the sam... |
0d565068487c72f833baaf8c0a3b54b04ce1b24c7bdff620a8834e6161643b55 | Python | 11,023 | 293 | import os
import numpy as np
import logging
from time import time
from tqdm import tqdm
import gc
import math
import torch
import torchkbnufft
from torchkbnufft._nufft.fft import ifft_and_scale
from .mtypes import DatBasics
from .coils import coil_combine
from .pf_handling import POCS
def correct_kspace_and_save(... |
f8ad84d86d6b2039b881dae02bd51c5bb443c359fb306901ecfa77b1c33a7eab | Python | 11,038 | 291 | # 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... |
40e01cc50ebaee752696ee16eb30a7907594052533e29627a7d8d0a6869c8161 | Python | 11,039 | 252 | from einops import rearrange
import torch.nn.functional as F
import torch
from typing import Dict, List, Tuple, Optional
import re
def adapt_conv_kernel_size(
pretrained_weight: torch.Tensor,
target_kernel_size: List[int],
pretrained_kernel_size: List[int],
) -> torch.Tensor:
"""
Adapt convolution... |
7072fd76ccf19b35b08ed26048b8ad75f9cf3f657a90edad7b32d2e3c2e7fc56 | Python | 11,082 | 235 | #!/usr/bin/env python
#
# Copyright (c) 2024 10X Genomics, Inc. All rights reserved.
#
"""Determine whether or not the cell annotation stage should run."""
__MRO__ = """
stage CELL_ANNOTATION_PREFLIGHT(
in bool is_cr_annotate,
in bool is_multi,
in string tenx_cloud_token_path,
in string cell_an... |
28650f1d78e2c66b49f7dfdeb5a1d3dd510d65141222a3d2a40ad00d39e4f82a | Python | 11,085 | 279 | #!/usr/bin/env python
#
# Copyright (c) 2018 10X Genomics, Inc. All rights reserved
#
"""Assign protospacers to cells.
Identify which cells express which protospacers above background.
"""
from __future__ import annotations
import csv
import json
import math
import operator
from collections import defaultdict
from c... |
72741cd8476ef7de379af13b8ee64369f69adf4c3ac69b609c8c01e17b10bfc8 | Python | 11,085 | 324 | import torch
import os,time
from torch import nn
import torch.nn.functional as F
import torch.optim as optim
import numpy as np
from tqdm import tqdm
from torch.utils.data import Dataset
from torch.utils.data import DataLoader
import random
class LocalLinear(nn.Module):
def __init__(self,out_size,mask,bias=True):
... |
a52cd2f92b5b6824c90f9cfaa33983e008aab47d872efcb416aaa370a7307349 | Python | 11,087 | 196 | """Reproduce the LLM/human interrater validation (Supplementary Information).
Validates the LLM judge (GPT-5) used for the free-form text-rationale
analysis against two human raters on the 6 non-expert participants that both
humans rated (6 participants x 3 scenarios x 3 anchors = 54 judgments).
Reports raw agreement ... |
f695209ac9b0322805972677d91eea19772a3ce7d8187b7d120b7d22698ac5ce | Python | 11,094 | 268 | from __future__ import annotations
import os
import re
import shutil
import subprocess
import uuid
from dataclasses import dataclass
from pathlib import Path
from typing import Any
from rdkit import Chem
from rdkit.Geometry import Point3D
from src.quantum.mopac_methods import normalize_mopac_method
from src.utils.mo... |
7ba97113988ce0167d653ec5b0bac2a63f91d8807d4d222d60ecf58d787584e7 | Python | 11,101 | 304 | """
Tutorial 3: Null models for gradient significance
==================================================
In this tutorial we assess the significance of correlations between the first
canonical gradient and data from other modalities (curvature, cortical
thickness and T1w/T2w image intensity). A normal test of the signi... |
5e7271b911fe0e1007011cc9bf3e8599a54741aee888ffdca9df5927f6a60acd | Python | 11,119 | 265 | import numpy as np
import matplotlib.pyplot as plt
from holoviews.plotting.bokeh.styles import alpha
import matplotlib as mpl
from matplotlib.ticker import FixedLocator, FixedFormatter
import pandas as pd
import os
from elephant.statistics import isi, cv, mean_firing_rate, instantaneous_rate
from elephant.spike_train_s... |
bd9fcf8357559f449d5929033095be2b5c74169960fc3e2e55e2546e13c967a3 | Python | 11,127 | 371 | from abc import abstractmethod
from typing import Sequence
from lightning.pytorch.core.mixins import HyperparametersMixin
import torch
from torch import Tensor, nn
from torch.nn import functional as F
from chemprop.conf import DEFAULT_HIDDEN_DIM
from chemprop.nn.ffn import MLP
from chemprop.nn.hparams import HasHPara... |
7643cd449e56533902abeb2e54b58f5a0d03db37380e7b74e46c6d22ec08280c | Python | 11,129 | 259 | """How a built-in NBLAST is split into blocks, dispatched and reassembled.
Everything here pins the *builtin* backend explicitly. navis-fastcore computes
the whole matrix in a single Rust call and never touches this machinery, so
letting `backend="auto"` decide would silently stop testing it on any machine
that has fa... |
4746bf1016a919627fe247ed697b23c7250deffde7358eae0a0a345075fea58d | Python | 11,130 | 249 | """
07_uncertainty_vs_pseudotime.py
on-manifold fluctuation (u_dyn_par) と off-manifold instability (u_dyn_perp) を
pseudotime に沿って散布図 + LOWESS トレンド曲線で可視化する。
対象クラスター: TAC, HS-TAC, Hair Shaft-Cuticle/Cortex, Medulla
RNA / ATAC それぞれ独立したプロットを生成する。
y 軸上限はプロット対象データの 95 パーセンタイル値とする。
出力 (save_dir/):
RNA:
uncertainty_vs... |
c6369d072027b7d45a04aca44938ecd74417b07e68f39f7786fc2ebee79e7846 | Python | 11,141 | 307 | """
Coloring
========
<!-- difficulty: beginner -->
Control neuron colors, palettes, opacity and depth cues - in every backend.
Color is the one part of {{ navis }}' plotting API that works the same everywhere: the parameters
below behave identically whether you are drawing a static figure with [`plot2d`][navis.plot2... |
d2e3df37726e21f59204e55c2a99b332906e01f2885b8f524533f13371d91bee | Python | 11,150 | 359 | """Helper functions and classes for tests"""
from __future__ import annotations
import functools as ft
import itertools as it
import re
import subprocess as sp
from collections.abc import Callable, Iterable, Mapping, Sequence
from datetime import timedelta
from pathlib import Path
from typing import (
Any,
Pr... |
aee75a820576e31c5c5d5039514d0e0c33518c1b4354939dbcba247af386ff1d | Python | 11,156 | 272 | # Copyright (c) Facebook, Inc. and its affiliates.
from typing import List
import torch
from torch import nn
from torch.nn import functional as F
from detectron2.config import configurable
from detectron2.layers import Conv2d, ConvTranspose2d, cat, interpolate
from detectron2.structures import Instances, heatmaps_to_k... |
428c43def50b8bde51cac0ace2e48caa48729e84b58b5ef9d36d86562c887247 | Python | 11,170 | 279 | """Tests for the VAE: featurisation, training steps, k-fold, and bundles.
Generation is half of this package's remit, so the VAE path is covered here
end to end: featurisation shapes, the loss, a training step, k-fold, and the
bundle round-trip.
"""
import numpy as np
import pandas as pd
import pytest
import torch
fro... |
d8697fc7454fc4c9b4ecc59b380de36242c3319dfe0ead1bef47666be628ee11 | Python | 11,170 | 209 | import argparse
import inspect
import numpy as np
import os
from os.path import join
from pathlib import Path
from time import time
from typing import Union, Tuple
import warnings
import torch
from torch._dynamo import OptimizedModule
from nnunetv2.utilities.label_handling.label_handling import LabelManager
from acvl... |
e0b7ac99e26971c59da5ba099a46a56a3f264e26b8febe6dd95d02e11fef2797 | Python | 11,175 | 271 | # Copyright (c) Facebook, Inc. and its affiliates.
import logging
import numpy as np
import torch
from detectron2.config import configurable
from detectron2.layers import ShapeSpec, batched_nms_rotated
from detectron2.structures import Instances, RotatedBoxes, pairwise_iou_rotated
from detectron2.utils.events import g... |
ca252efc8b6a71c4d9dbe45f60ec9149ca276edfc80cb71057a0a95c9f5440f3 | Python | 11,177 | 237 | import os
import sys
from argparse import ArgumentParser
import numpy as np
import scanpy as sc
import torch
import pytorch_lightning as pl
from pytorch_lightning.callbacks.model_checkpoint import ModelCheckpoint
from pytorch_lightning import loggers as pl_loggers
sys.path.append("/home/nomura/Proj/mmvelo/src")
from m... |
f30972621864abf2f5176fcbc622c069ab88c5d521f7b906dda44dcc31b3b1ac | Python | 11,182 | 327 | # This code is part of OpenFE and is licensed under the MIT license.
# For details, see https://github.com/OpenFreeEnergy/openfe
import pytest
from gufe import LigandAtomMapping, ProtocolDAGResult
from openff.units import unit as offunit
from openfe import ChemicalSystem, SolventComponent
from openfe.protocols import ... |
68c9209a84184721ce2d8bb8304fd3f8c346e73ad8849f1776eb5730a797a196 | Python | 11,189 | 308 | import math
import torch
import torch.nn as nn
from torch import Tensor
from typing import Union, Tuple
def get_activation(type: str, dim: int) -> nn.Module:
if type == "relu":
return nn.ReLU()
elif type == "leaky_relu":
return nn.LeakyReLU()
elif type == "elu":
return nn.ELU()
... |
f3eac730a806de35738285a4477b3d95f121be461e5b96c55918da6159be2b6c | Python | 11,201 | 324 | # AUTOGENERATED! DO NOT EDIT! File to edit: 30_stats_binding.ipynb (unless otherwise specified).
__all__ = ['NonlinearBase', 'sigmoid', 'occupancy', 'delta_occupancy', 'get_biophysical_parameters',
'get_max_change_in_binding', 'get_shape_parameters', 'relative_change_in_occupancy',
'modified_rela... |
2309afe3455ccf1b07ebfc37c84f4b3eef0066fcf6da0c4016ca5ebfe5c965a2 | Python | 11,202 | 256 | import numpy as np
import nibabel as nib
import monai
from monai.transforms import (
AddChannel,
Resize,
Spacing,
ResizeWithPadOrCrop
)
import matplotlib.pyplot as plt
import warnings
warnings.filterwarnings("ignore")
import argparse
import os
import ants
def get_dims(shape, max_channels=10):
"""G... |
64ed9893893a72cb28b5bfe76187ea3d8729234e898aa2d61334170edd726fd5 | Python | 11,204 | 277 | """Generate all Figure 5 panels.
Panels:
1. Pie chart (PL classification pattern across currents)
2. Pyramidal fraction PL vs NPL
3. PL modulation over weeks
4. PL time to max FR over weeks
5. PL P(spike) over weeks
6. NPL fraction early vs late
Usage (from repo root):
python -m python.fig5.generate_f... |
0cc21a83c4ac7c994b7424409990dc24b7220b413b879e58bd1c5de05868781f | Python | 11,218 | 350 | """ Created on Mon Oct 23 12:23:47 2023
@author: dcupolillo """
import numpy as np
from scipy.ndimage import binary_dilation
from skimage.measure import moments
import tensorflow as tf
def threshold_prediction(
prediction: np.ndarray,
threshold: float
) -> np.ndarray:
"""
Apply a binary t... |
7f98cecd253c23364e32f025cb46fbfffb66596bce3a9842217224df2c4147e7 | Python | 11,219 | 308 | #!/usr/bin/env python3
"""
===============================================================================
attention2pdb.py — Map EGNN attention scores onto PDB B-factors for visualization.
Reads an attention CSV (from your predictor/attention export) and writes a copy of the
input PDB where the B-factor field holds s... |
3ef75cbceec84309041750b1451dec369005950c1bdaff2c708e922d977455cf | Python | 11,229 | 291 | """Tests for the cluster backends: dask.distributed and submitit.
These run against real machinery - a local dask cluster and submitit's local
executors - because the interesting failures are the ones a mock cannot have:
whether a neuron survives cloudpickle, whether results come back in input
order, and whether a wor... |
52c371c92bc4581eae84a06b74df5e7d81e8a2b0e886b3fd15165f000e65bf16 | Python | 11,240 | 515 | #!/usr/bin/env python3
#
# Copyright (c) 2025 10X Genomics, Inc. All rights reserved.
#
"""Martian Python types."""
from __future__ import annotations
from typing import TYPE_CHECKING, Any, TypedDict
if TYPE_CHECKING:
from cellranger.mro_types.filetypes import (
bam,
bam_bai,
bam_csi,
... |
7d6b3b3d2b29d90b51ed7b6d7ad1266c9a170cc91d70259cdac1c9f736ac0885 | Python | 11,245 | 422 | # %%
from __future__ import annotations
import os
import os.path as op
import sys
import gif
import joblib
import matplotlib.patches as patches
import matplotlib.patheffects as path_effects
import matplotlib.pyplot as plt
import numpy as np
from joblib import delayed
from joblib import Parallel
from matplotlib import... |
61d83a71017ad46b37908a8370023434246fa0a255a016daddb5bc03e24f74bd | Python | 11,247 | 279 | # -*- coding: utf-8 -*-
"""ml_frost_statistical_evaluation
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/16Uio2qfOPcNDA_iyEX4eCXoymNBVqJ2O
Friedman–Nemenyi comparison of binary and multiclass classifiers, with a
combined critical difference (CD) diagram.
T... |
d02e7bc89e1c52e2303e828459a96accbfdf0f6b8bc54f885ca13c8f087e1718 | Python | 11,252 | 344 | # %%
from __future__ import annotations
import os
import re
import sys
from collections import defaultdict
import mne
import pandas as pd
from wasabi import msg
mne.use_log_level(verbose='ERROR')
mne.cuda.init_cuda(verbose=True)
def loading_(start='Processing...'):
end = f'{start} Done!'
def decorator(func... |
1710c8167c12fe960e3ba6ba7eda89ece5a7206c18ee91d7db52000b7ca205eb | Python | 11,255 | 213 | # Copyright (c) Facebook, Inc. and its affiliates.
import os
from typing import Optional
import pkg_resources
import torch
from detectron2.checkpoint import DetectionCheckpointer
from detectron2.config import CfgNode, LazyConfig, get_cfg, instantiate
from detectron2.modeling import build_model
class _ModelZooUrls:
... |
5a3a67f30ee7da1d586d0f0141785dc6f1a4ba3ac12524aa693a860cb5675227 | Python | 11,260 | 268 | # -*- coding: utf-8 -*-
# Copyright (c) Facebook, Inc. and its affiliates.
import logging
import numpy as np
import unittest
from unittest import mock
import torch
from PIL import Image, ImageOps
from torch.nn import functional as F
from detectron2.config import get_cfg
from detectron2.data import detection_utils
fro... |
1a3acbd1dc433bbfb8bd202f9a70dd7c2be601cf28719fc0c639c3888a8a77db | Python | 11,262 | 245 | #!/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... |
929def20f87f875c6232e3168c4cc9ecfe0e832b6691a1fa66a04f138d31ebbf | Python | 11,270 | 262 | # Copyright (c) Facebook, Inc. and its affiliates.
import logging
import unittest
import torch
from detectron2.config import get_cfg
from detectron2.export import scripting_with_instances
from detectron2.layers import ShapeSpec
from detectron2.modeling.backbone import build_backbone
from detectron2.modeling.proposal_g... |
7f68885bb289cbcf46c1f191fd74bea77f958596ceb00ab3460286a77fc0c32f | Python | 11,283 | 309 | """
If you use this code, please cite one of the SynthSeg papers:
https://github.com/BBillot/SynthSeg/blob/master/bibtex.bib
Copyright 2020 Benjamin Billot
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 Lice... |
1cf09f3f9538bce3f6a8ea05870a3ae6cb8e70200148eb547f4a40baacfefaa3 | Python | 11,285 | 281 | """Montreal Forced Aligner integration."""
import os
import re
import shutil
import signal
import subprocess
from pathlib import Path
import librosa
import soundfile as sf
from praatio import textgrid as tgio
from .config import TAPAConfig
def prepare_mfa_input(audio_path, words, temp_dir, cfg=None, audio_np=None)... |
98cc4ff699760da749737273a7dac599507d9bfb55ca8b7922a1ec077d9cd409 | Python | 11,285 | 342 | import os
import time
import shutil
import numpy as np
import torch
import h5py
from torchsummary import summary
from sklearn.utils.class_weight import compute_class_weight
from omegaconf import OmegaConf
import lightning as L
from lightning.pytorch import seed_everything
from lightning.pytorch.loggers import TensorB... |
c8bcdbe3894ef7b601df4842e8b986da8115fabee8473d55938d0b70f98b76fc | Python | 11,289 | 315 | """Tests for dataset splitting strategies, including stratified regression."""
import numpy as np
import pytest
from nfml.data.splitting import (
_bin_regression_targets,
random_split,
scaffold_kfold,
scaffold_split,
stratify_labels,
)
# ----------------------------------------------------------... |
7a057600eb17dbd4f39714dc5c6882c4cd7236fc5fd83e370dd99b6882e9599f | Python | 11,291 | 307 | #!/usr/bin/env python
# Copyright 2016-2022 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... |
5a12f6b2a1ee7e63bfced3e629980492dc3e330fb1c901518b195bf4c70865aa | Python | 11,316 | 287 | # Copyright (c) Facebook, Inc. and its affiliates.
import numpy as np
from typing import List
import pycocotools.mask as mask_util
from detectron2.structures import Instances
from detectron2.utils.visualizer import (
ColorMode,
Visualizer,
_create_text_labels,
_PanopticPrediction,
)
from .colormap imp... |
da2c0d8485a0c5040275c390189c5bc80f0815aa07153777944dc876afa58ec8 | Python | 11,323 | 311 | """ Evaluation of a model """
__author__ = "Fabi Bongratz"
__email__ = "fabi.bongratz@gmail.com"
import re
import os
import glob
from collections.abc import Sequence
import numpy as np
import torch
import trimesh
import pandas as pd
import nibabel as nib
from torch.nn.parallel import DistributedDataParallel as DDP
f... |
6fa136156ec3ff120b0ca1ea16375c12c8f32b098338e94ff5522b307b9863e4 | Python | 11,341 | 155 |
############################################################################
# Copyright (c) 2022-2026 University of Helsinki
# All Rights Reserved
# See file LICENSE for details.
############################################################################
import pytest
from functools import partial
from isoquant_li... |
bb4fbea14bf361d7bf706ee39770cd7e79016021b8fd1d47c6a642b2d9e00407 | Python | 11,349 | 343 | import os
import pathlib
import sys
from typing import List, Literal
import click
import numpy as np
import pandas as pd
from openff.units import unit
from openfecli import OFECommandPlugin
from openfecli.clicktypes import HyphenAwareChoice
from openfecli.commands.gather import (
_collect_result_jsons,
format... |
7b9a27255e67c35ab5fc968943c8b2a012e9e1115c7de245988bd81114141531 | Python | 11,358 | 297 | """
Stage 1: preprocess + spike sort (MountainSort5) + auto-curate, per session.
Loads via the session-loader dispatch (standard DataLoader for Mouse 1-5, the
Mouse 6 loader for ICMS83), runs preprocess_icms, sorts, and auto-curates.
Output: <session>/batch_sort/stage1/
Usage:
python -m batch_process.stag... |
60a7e6f5341807984c4f2f9f0ab08c91ac06c8b3714ae320ff43bed331550407 | Python | 11,361 | 265 | # Copyright (c) Facebook, Inc. and its affiliates.
import itertools
import json
import logging
import numpy as np
import os
from collections import OrderedDict
from typing import Optional, Union
import pycocotools.mask as mask_util
import torch
from PIL import Image
from detectron2.data import DatasetCatalog, Metadata... |
2b1937c43e86e21a5249a06ffe4a45b33015dfd76fd22685143f465860fe54c4 | Python | 11,366 | 311 | """
Dataset for Axon Segmentation
Loads preprocessed 128×128 tiles (RGB image + binary axon mask) from the
directory structure produced by preprocess.py.
Expected data layout:
preprocessed_data/
├── train/
│ ├── Small_tiles_RGB/
│ └── Small_tiles_axon_masks/
├── val/
│ └── ...
└── te... |
4d5790952e6d29641e7daa94f6349df8d1f051e913db49acbc6087fe5d1a7395 | Python | 11,378 | 369 | """
Utility functions for parcellations/labelings.
"""
# Author: Oualid Benkarim <oualid.benkarim@mcgill.ca>
# License: BSD 3 clause
import numpy as np
from scipy.stats import mode
from scipy.optimize import linear_sum_assignment
from sklearn.utils.extmath import weighted_mode
def relabel_consecutive(lab, start_f... |
4570981804678788769260c3263a699c604b0c52762685fa3f1843b3890b2656 | Python | 11,389 | 267 | from __future__ import division
import ldscore.jackknife as jk
import unittest
import numpy as np
import nose
from numpy.testing import assert_array_equal, assert_array_almost_equal
from nose.tools import assert_raises
class Test_Jackknife(unittest.TestCase):
def test_separators(self):
N = 20
x =... |
ab4149c4bdd0710be87500fb9babae18260307fb2712e10afa6f9421827aa63a | Python | 11,402 | 251 | ############################################################################
# Copyright (c) 2022-2024 University of Helsinki
# # All Rights Reserved
# See file LICENSE for details.
############################################################################
# Tests for the splice-site error corrector (ported from PR ... |
c4c41f0a40ea30215298daebae29d2eff1ba2b3da1f7347cc3a8cfecafdc4cb5 | Python | 11,414 | 273 | import os
import time
from typing import Union
import torch.optim as optim
from matplotlib import pyplot as plt
from torch.utils.data import DataLoader, random_split
from tqdm import tqdm
from .losses import *
from .multi_output_unet3d import MultiOutputUnet3D
from ..utils import init_weights, get_device
class Trai... |
c44726c274bd31ff20cc1491375a3dc930e61e5dc2660a63e863ce607ceac213 | Python | 11,421 | 280 |
from __future__ import absolute_import
import numpy as np
import torch
from torch import nn
from collections import OrderedDict
from torch.autograd import Variable
from scipy.ndimage import zoom
from tqdm import tqdm
import lpips
import os
class Trainer():
def name(self):
return self.model_name
def... |
923b9d02b9595145a0bded74a194642e8e5fa735ca090bcc81141ec9fb56f4d3 | Python | 11,432 | 321 | #%%
from pathlib import Path
import sys
sys.path.append('/mnt/obob/staff/fschmidt/cardiac_1_f')
from utils.data_loading import data_loader
import bambi as bmb
from scipy.stats import zscore
import arviz as az
import pingouin as pg
import pandas as pd
import joblib
import numpy as np
import pymc as pm
import matplotlib... |
ddff54521437f332982ad700ea8b55c6ad40d3feb5566d93bcf2243ddf6589da | Python | 11,435 | 357 | # Copyright (c) 2026 10X Genomics, Inc. All rights reserved.
#
"""Non-matplotlib functions used in the HD clustering plot."""
# Turbo colormap data - precomputed RGB values at 256 positions
# This is the same colormap that matplotlib uses for 'turbo'
TURBO_COLORMAP_DATA = [
(0.18995, 0.07176, 0.23217),
(0.1948... |
6df31180a544a68c93f47b97c5bb28c53054672dc0b6ecccc56dd0e3c59c36a3 | Python | 11,441 | 242 | import os
from typing import Union
import numpy as np
import tifffile
import torch
from tifffile.tifffile import TiffFile
from tqdm import tqdm as tqdm
from bio_image_unet.progress import ProgressNotifier
from .siam_unet import Siam_UNet
from ..utils import get_device
class Predict:
"""
Class for prediction... |
b4b1a902c3d29aaeef037a7a57600179c7b3b1e6a93c9de910665273d5ee9a20 | Python | 11,470 | 339 | from __future__ import annotations
import argparse
import importlib.metadata as impm
import logging
import sys
from collections.abc import Callable, Sequence
from pathlib import Path
from typing import Any, TypeVar
import attrs
import more_itertools as itx
from typing_extensions import overload, override
from snakeb... |
c20dc4a9cbb5738a2b0c47b409c304293399099bd1c9490744497e18e5c60581 | Python | 11,471 | 350 | # This code is part of OpenFE and is licensed under the MIT license.
# For details, see https://github.com/OpenFreeEnergy/openfe
import pytest
from gufe import LigandAtomMapping, ProtocolDAGResult
from openfe import ChemicalSystem, SolventComponent
from openfe.protocols.openmm_afe import (
AbsoluteBindingProtocol,... |
35767a0d9465c16181ce36e96a53b3f15f23be5ba7d73e50e97d6d8be4204870 | Python | 11,509 | 263 | # Copyright (c) Facebook, Inc. and its affiliates.
import math
from typing import List, Optional
import torch
from torch import nn
from torchvision.ops import RoIPool
from detectron2.layers import ROIAlign, ROIAlignRotated, cat, nonzero_tuple, shapes_to_tensor
from detectron2.structures import Boxes
from detectron2.ut... |
51a600c61eec24921462a5cc24ebc0548600e9aa174921f1290d2018d4dbee31 | Python | 11,517 | 360 | #%% 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... |
128e720e7fd23b57ffe0279f7b1e45ccaeff5c11aee8d42dfb2ba69750460174 | Python | 11,518 | 303 | import matplotlib
from batchgenerators.utilities.file_and_folder_operations import join
matplotlib.use('agg')
import seaborn as sns
import matplotlib.pyplot as plt
from typing import Any
from pathlib import Path
import shutil
import os
try:
import wandb
except ImportError:
wandb = None
def get_cluster_job_i... |
ff8f5b7c2c5eb92387dbc50b055253426072c240c67ee2372d8810bcf8aea29e | Python | 11,518 | 298 | #!/usr/bin/env python3
""" Main file """
import os
import sys
import json
import logging
import random
from argparse import ArgumentParser, RawTextHelpFormatter
# Temporarily filter warnings
import warnings
warnings.filterwarnings("ignore")
import torch
import numpy as np
import logger
from data.supported_datasets... |
4342f3382d6f0126ac8b92578490ba045093a090a57ff3d24e1ffc1dc5fad64d | Python | 11,521 | 299 | ############################################################################
# Copyright (c) 2022-2026 University of Helsinki
# Copyright (c) 2019-2022 Saint Petersburg State University
# # All Rights Reserved
# See file LICENSE for details.
############################################################################
... |
74539f8bf5eafd6edb75a6cd7b45890d1896508e3c6162a620251517d39343d6 | Python | 11,526 | 406 | # Copyright (c) Facebook, Inc. and its affiliates.
import os
import sys
import tempfile
from contextlib import ExitStack, contextmanager
from copy import deepcopy
from unittest import mock
import torch
from torch import nn
# need some explicit imports due to https://github.com/pytorch/pytorch/issues/38964
import dete... |
d5b9ecbf0935d9ef1affb5559ec2ea6d20175be0bc52f62dfef8c1149b3a7fbb | Python | 11,527 | 376 | # This code is part of OpenFE and is licensed under the MIT license.
# For details, see https://github.com/OpenFreeEnergy/openfe
import gzip
from importlib import resources
from typing import Optional
import openmm
import pooch
import pytest
from openff.units import Quantity, unit
from openff.units.openmm import from_... |
bb2d6ecfc82f7c3bc900ae042ef42cde89813fd003f6356b2a7c75916ef9aa60 | Python | 11,531 | 294 | import numpy as np
import pandas as pd
import warnings
import time
warnings.filterwarnings("ignore")
import matplotlib.pyplot as plt
import re
import argparse
import os
import pre_process
from monai.networks.nets import DenseNet
import torch
import nibabel as nib
import tqdm
import datetime
from collections import Or... |
2f1fecc84e7b51be0716422a6b47e47b9871a28dc71c3b884a8e726c2944fb48 | Python | 11,553 | 415 | import os
import string
import numpy as np
import pandas as pd
from sklearn.preprocessing import normalize
from utils import load_pickle
def load_datum(file_name):
"""Read raw datum from pickle
Args:
filename (string): raw datum full file path
Returns:
df (df): datum
"""
datum =... |
b574f599357ad43d00415625e607abb5ef39dca7581328c60b11ab4f4ee0c2da | Python | 11,579 | 278 | from io import StringIO
import re
from lightning import pytorch as pl
from lightning.pytorch.callbacks.progress.tqdm_progress import Tqdm, TQDMProgressBar
import pytest
import torch
from torch.nn import functional as F
from torch.utils.data import DataLoader, Dataset
from chemprop.nn.metrics import (
MAE,
MSE... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.