sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
6fa3c08d730d03dfc9f76b6098fc136a10ba353a09885be8084aa3dabf508f9f
Python
7,199
239
# %% from __future__ import annotations import os import os.path as op import sys from dataclasses import dataclass import mne import pandas as pd from wasabi import msg from src.epoching import Epoching from src.epoching import InfoExtraction sys.path.append(op.abspath('..')) # %% ROOT = '../../NOD-MEEG_upload' # ...
fef18610ce1734d0feabaac8ae400e5883393a749967c49f4c0e6afc62842789
Python
7,207
178
""" Volumes ======= <!-- difficulty: intermediate --> Give a figure context without letting the neuropil steal it. [`Volumes`][navis.Volume] - neuropils, brain outlines, ROIs - are meshes, so most of what the [mesh tutorial](../tutorial_plotting_2d_01_meshes) says applies here too. What makes them their own topic is ...
d772e748196417252e93d23aa33c725f976dc5b6b2cfe9e90119a1c7b873f0e8
Python
7,211
188
#!/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...
99c9ec60ba4da703493d02ccbf72239a4350d9500ac011a61cc4a448ab51d1ce
Python
7,212
178
"""実験1を実行するプログラム""" import numpy as np from Agent_intermittent import BGmodel from Environment import InvertedPendulum from scipy import signal import myfunc0829 import blosc2 import os #num_list = [i+1 for i in range(8)] # 格納したいトライアルのリスト(一つのトライアルにつき210秒分の時系列データが入る) #num_list = [1,2,3,4,5,6,7,8,9,10,11,12,13...
e64570ea703dd919e6e9e64daf5956b9e01c2c46f02856d1d85234d56058e808
Python
7,214
154
############################################################################ # Copyright (c) 2022-2026 University of Helsinki # All Rights Reserved # See file LICENSE for details. ############################################################################ from enum import Enum, unique from isoquant_lib.common impor...
f88dfecd9e0cfca59797ec43ee244d2bbe24d07cb1185bdefd38823759fb30e8
Python
7,215
194
# Copyright (c) Facebook, Inc. and its affiliates. import argparse import glob import multiprocessing as mp import numpy as np import os import tempfile import time import warnings import cv2 import tqdm from detectron2.config import get_cfg from detectron2.data.detection_utils import read_image from detectron2.utils....
bb147d1a16e9dadf17c6972c4f491e51dfb281fbb67f0b867b3fd4660d8e81e8
Python
7,216
147
############################################################################ # Copyright (c) 2022-2026 University of Helsinki # Copyright (c) 2020-2022 Saint Petersburg State University # # All Rights Reserved # See file LICENSE for details. ############################################################################ ...
5fcb9596dbb1f8ea2fde760f32f62b8ad0198f9c8f97d9b6edfaf662df02f24e
Python
7,223
223
#%% import joblib from os.path import join import numpy as np import pandas as pd import matplotlib as mpl new_rc_params = {'text.usetex': False, "svg.fonttype": 'none' } mpl.rcParams.update(new_rc_params) import matplotlib.pyplot as plt import seaborn as sns import sys sys.path.append('/mnt/obob/s...
c3585ced4e6732fbe0334d7f99f9df377f2940d84e2b1a569c9cbd1192a41754
Python
7,224
236
# Copyright (c) Facebook, Inc. and its affiliates. import copy import logging import types from collections import UserDict from typing import List from detectron2.utils.logger import log_first_n __all__ = ["DatasetCatalog", "MetadataCatalog", "Metadata"] class _DatasetCatalog(UserDict): """ A global dictio...
98e57d2c7e57f98aa3c292a00b2e762462e10b072c87c96124a5343fd23769dc
Python
7,230
156
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved # pyre-unsafe from typing import Any, List import torch from torch import nn from torch.nn import functional as F from detectron2.config import CfgNode from detectron2.structures import Instances from densepose.data.meshes.catalog import MeshCat...
d307973ee78d8e8e31f12bebeda69437145de7d33d32b88d3744975cfb7bdd38
Python
7,236
183
# type: ignore import numpy as np import pandas as pd import pytest from hsnn.analysis import png from hsnn.pipeline import reuse from hsnn.utils import handler @pytest.fixture def polygrps(): png_a = png.PNG( layers=np.array([3, 4, 4]), nrns=np.array([10, 20, 30]), lags=np.array([0.0, 3.0, 10.0]...
110ec90e339aecc9ef26c369e0f9b1ab1ab0a0856d6e2c444e369937452d7748
Python
7,237
238
# Copyright (c) Facebook, Inc. and its affiliates. """ This file contains primitives for multi-gpu communication. This is useful when doing distributed training. """ import functools import numpy as np import torch import torch.distributed as dist _LOCAL_PROCESS_GROUP = None _MISSING_LOCAL_PG_ERROR = ( "Local pro...
0a46e0fd13f0c6719f9aa102b1f069b9c1523f1df24f976bd08f2307a0e425ee
Python
7,241
162
""" utils/io.py ----------- All file output: TSV tables, CSV tables, and the criticality text report. The R script for LTP/LTD reads the TSV files produced here. Keep column names stable — changing them breaks the R script. """ import io import os import re import sys import platform import datetime import numpy as np...
717df07d25b71057c3bfcd7728f79ae39e007fc7b3ea459499d9419c967567bb
Python
7,248
185
"""UnitResponse — stores per-unit spike data and stim condition responses.""" from .stim_condition_response import StimConditionResponse import numpy as np import batch_process.util.template_util as template_util class UnitResponse: def __init__(self, unit_id, spike_timestamps, session_responses): self._...
3b56ceb3a4c5477882584cb2a83e4e29598ea41b2d1e0fb54cb731c4ce0f43f7
Python
7,256
178
"""実験1を実行するプログラム""" import numpy as np from Agent_continuous import BGmodel from Environment import InvertedPendulum from scipy import signal import myfunc0829 import blosc2 import os #num_list = [i+1 for i in range(8)] # 格納したいトライアルのリスト(一つのトライアルにつき210秒分の時系列データが入る) #num_list = [1,2,3,4,5,6,7,8,9,10,11,12,13,1...
096d484f26811a2d1e3b229558949960974b8e4bdfbd4cdb76061874843fb9d1
Python
7,260
170
from __future__ import annotations from abc import ABC, abstractmethod from typing import Any, Dict, Iterable, List, Optional, Tuple, Type import numpy as np import numpy.typing as npt import pandas as pd import xarray as xr from brian2 import CodeRunner, Network, NeuronGroup, Synapses, SpikeMonitor, StateMonitor fro...
9b1a1740fe157c42c6bff4824880822d069da610e0ee74790f41a3bf5f34729b
Python
7,264
188
# Generated by Django 4.2 on 2024-10-02 08:58 from django.conf import settings import django.contrib.auth.models import django.contrib.auth.validators from django.db import migrations, models import django.db.models.deletion import django.utils.timezone class Migration(migrations.Migration): initial = True ...
44820fe41d4e59439d7469bf5e3c1fb7e92a27134cf8cd83e94045db9b55291f
Python
7,265
202
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. import contextlib import io import numpy as np import unittest from collections import defaultdict import torch import tqdm from fvcore.common.benchmark import benchmark from pycocotools.coco import COCO from tabulate import tabulate from torch...
31c76cdb2eefed27d4e335d31ddf4f21936939eae6668f90f8548a88643a9046
Python
7,272
231
import csv import os import numpy as np import pandas as pd import torch from himalaya.kernel_ridge import (ColumnKernelizer, Kernelizer, KernelRidgeCV, MultipleKernelRidgeCV) from himalaya.ridge import ColumnTransformerNoStack, GroupRidgeCV, RidgeCV from himalaya.scoring import corr...
d747aed6f1c2fde9082cac7a1ab328e0e335393ad86c35077ad256328c660086
Python
7,281
230
from pathlib import Path home = Path.home() [x for x in home.iterdir()] inpD = '1d/UTR' [x for x in (home/inpD).iterdir()] inpF=home/inpD/"data2.csv" import pandas as pd #import modin.pandas as pd data = pd.read_csv(str(inpF)) data.head() data.describe() import matplotlib.pyplot as plt import numpy as np data['RFPlog...
5bd2e958f44ba959f4be1296a33284549e4e84c28cace2abc9802190321bfe9b
Python
7,283
242
# -*- coding: utf-8 -*- """ Created on Mon May 1 14:59:05 2023 @author: walte """ import os import random import numpy as np import imageio from tqdm import tqdm import torch import csv from collections import OrderedDict #################### # Resuming training #################### # def get...
02449632dd6b494d130215c82444bd26db9f0b9266225d7cbce73b18c0e545a9
Python
7,286
232
"""Tests for meta-agent creation, discovery helpers, and group reuse.""" import pytest from mesa import Agent, Model from mesa.discrete_space.cell_agent import CellAgent from mesa.discrete_space.grid import OrthogonalMooreGrid from mesa.meta_agents import MetaAgents from mesa.meta_agents.meta_agent import MetaAgent ...
d64287a2c6a9284c13ad50be8a56294f36f66413eaed56163d7702f84682ac6e
Python
7,292
168
############################################################################ # Copyright (c) 2022-2026 University of Helsinki # All Rights Reserved # See file LICENSE for details. ############################################################################ import pysam import logging from isoquant_lib.common import ...
5953911194d47a23aef6f42695284e63e987496be0ac5c7bfbd8a6cc34a2dc34
Python
7,297
228
#%% import numpy as np from lisc import Words, Counts from lisc.plts.counts import plot_matrix import matplotlib.pyplot as plt import networkx as nx import seaborn as sns from lisc.plts.words import plot_years, plot_wordcloud from lisc import Counts from lisc.plts.utils import check_args, check_ax # counts_data_helper ...
246f051c507492f6861ae505535b13fa1e2172f13e4407364212df2c8d8ae2e7
Python
7,310
136
from typing import Union, List, Tuple, Callable import numpy as np from acvl_utils.morphology.morphology_helper import label_with_component_sizes from batchgenerators.transforms.abstract_transforms import AbstractTransform from skimage.morphology import ball from skimage.morphology.binary import binary_erosion, binary...
c27c98ea11a2c3d8b031188553441fd9f59abff09baa669191d13797d1a66a83
Python
7,310
177
""" loaders/maxwell_loader.py -------------------------- Loader for Maxwell Biosystems .h5 files (data.raw.h5). HDF5 structure expected ----------------------- /data_store/<stream>/ spikes – structured array with fields: frameno (int64) ...
941f6251e1565d19c5c3e1dfa55aa0a0552827752bfcbb471cce36c22498222b
Python
7,313
193
"""A module to provide an interface to the subprocess library. This module hosts the functionality for streamline the execution of command-line algorithms called from the subprocess library. This is convenient when parsing through gear configuration parameters and inputs specified in a gear configuration (e.g `config...
c55bc1bdb0e5934924c4981a8c98e79692d62ebfa7d5f3ec352ce9ea97ab8af5
Python
7,314
198
""" Process and plot control session responses. Workflow: 1. Create session responses (or load from pickle) 2. Extract modulation metrics → CSV 3. Generate per-unit × per-channel figures → PNG 4. Compile figures into PowerPoint Usage: python process_control_responses.py <session_dir> python process_control_re...
4d3e0d682ab1624494df13519442365d5e0f4ac687665b159ca32826a9f7a7d7
Python
7,315
244
""" Created on Fri Aug 2 14:58:52 2024 @author: dcupolillo """ from __future__ import annotations import pyabf import numpy as np from tqdm import tqdm from typing import TYPE_CHECKING if TYPE_CHECKING: from spyne.core.electrophysiology.ephydataset import EphyDataset adc_dict = { 'IN 0': 'patch', 'I...
7a29118e0122cdaa3cedf8c69b8d07c6a7f3a526ef255d2e7432771c5382b512
Python
7,315
200
#!/usr/bin/env python3 """ Module: train.py Description: - Train specified model on a given dataset (pre-split). - Logs epoch-wise metrics, selects best model, and saves it. """ import os import sys import time import argparse from datetime import datetime import torch import torch.optim as optim import torch.nn ...
e34fb6e83fb79ce7e0130a6062df32d3c2b9aad00ae91b3aa791a0c9c624cfd1
Python
7,320
226
#!/usr/bin/env python3 ############################################################################ # Copyright (c) 2022-2026 University of Helsinki # All Rights Reserved # See file LICENSE for details. ############################################################################ """Convert read_info.tsv to legacy rea...
045b5fbd03163466d165c20eba0d329228fbbfbed176d5ba42f7b38e986cdfb1
Python
7,324
175
#!/usr/bin/env python # # Copyright (c) 2022 10X Genomics, Inc. All rights reserved. # """Code to produce plotly treemap plots.""" from __future__ import annotations import json import numpy as np import plotly.graph_objects as go from cellranger.rna.library import ANTIBODY_LIBRARY_TYPE from cellranger.websummary.i...
4bea3d1b7decc6adab5623d1682c668fe1ac01e6ada1bdab0f32ba5269004ea4
Python
7,324
232
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Text Embedding Generation for Patent Data This script generates BERT embeddings for patent abstracts using a pretrained model specifically designed for patents (anferico/bert-for-patents). Features: - Processes patents_{year}_*.parquet files - Filters for utility pat...
2314f8c0885608071e026d2e76cb523d2181611123d9a99381cc3c76cfae6b79
Python
7,338
200
import random import numpy as np import seaborn as sns import torch import torch.nn.functional as F from sklearn.metrics import roc_auc_score, average_precision_score, balanced_accuracy_score, roc_curve, cohen_kappa_score import matplotlib.pyplot as plt from transformers import AutoTokenizer import os from PIL import I...
4c47bdf0a71ad7ca44b0929f9474e623f7fc18e9f5c96399f7167132ac4d9286
Python
7,353
193
# Copyright (c) Facebook, Inc. and its affiliates. # pyre-unsafe from typing import Dict import torch from torch.nn import functional as F from detectron2.structures.boxes import Boxes, BoxMode from ..structures import ( DensePoseChartPredictorOutput, DensePoseChartResult, DensePoseChartResultWithConfid...
be2d71d647226c476fcb6b283c0ee4b58bf0fbd8fe620699f6f5e08e24f14b34
Python
7,354
171
"""Hit vs miss delta_spks histograms and KL divergence (700ms and 120ms).""" import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parents[1])) import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import numpy as np import pandas as pd import seaborn as sns from scipy.s...
03c09a48b3f3db5469aa8cf66d2558050078c5f9725f31887263d61510c4153e
Python
7,367
172
# Copyright (c) Facebook, Inc. and its affiliates. from __future__ import absolute_import, division, print_function, unicode_literals import numpy as np import unittest from copy import deepcopy import torch from torchvision import ops from detectron2.layers import batched_nms, batched_nms_rotated, nms_rotated from de...
159fa30b8c3bac6845f527a6bfaf5c7993ca25db1f7d6b377187b7fc6666d7f7
Python
7,372
189
#!/usr/bin/env python3 import argparse import csv import re from pathlib import Path from typing import List, Tuple, Dict, Optional from Bio import SeqIO, pairwise2 from Bio.PDB import PDBParser, MMCIFParser from Bio.PDB.Polypeptide import protein_letters_3to1 def parse_active_sites(spec: str) -> List[int]: """P...
5cdb059625737abcfd44f5add0efe4e87865ecd17bc8b9959380823bee8cdff6
Python
7,375
173
from __future__ import annotations from abc import ABC, abstractmethod from typing import Optional, Sequence, Type import numpy as np import numpy.typing as npt from scipy.stats import entropy import hsnn.simulation.functional as F from hsnn import analysis from hsnn.analysis import activity, measures from hsnn.anal...
32fa3db42a3d56c1103b7c21fcb1d1ac54f88e1eae53d09254dd35a3aab75ed2
Python
7,378
225
# Copyright (c) Facebook, Inc. and its affiliates. import logging import numpy as np from itertools import count from typing import List, Tuple import torch import tqdm from fvcore.common.timer import Timer from detectron2.utils import comm from .build import build_batch_data_loader from .common import DatasetFromLis...
3a709990c286328fd559978e7fee0f623e3e4bc05bde72a30c38e21b82704fba
Python
7,380
202
#!/usr/bin/env python # Copyright 2019-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...
c6f5ccb4a83f5146a7a60e33df015c51c4744bc6df63211c2e30036c7b2f9a6d
Python
7,382
162
import numpy as np import pandas as pd import warnings 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 OrderedDict im...
4122f6816253a357d22e9253d2839cf16e039953a83cb7153fa87c6506b24f8b
Python
7,395
228
#!/usr/bin/env python """ author:CBJ """ import sys from pathlib import Path import logging import numpy as np import torch import torch.nn as nn from torch.utils.data import DataLoader, TensorDataset import json PROJECT_ROOT = Path(__file__).parent.parent sys.path.insert(0, str(PROJECT_ROOT)) from src.models import...
dfce2e302c4b7f3c9d091afd49484a77ab8ee3f7e9e1d6f05de3d3f70f881464
Python
7,400
147
#!/usr/bin/env python3 """Build the small, hand-curated metadata JSON files the MCP server reads alongside data/studies.json: data/review_metadata.json citation, ids, links, licence, PRISMA counts data/eligibility.json Appendix S1 (PCC framework) + the 6 numbered inclusion/ex...
5c8fc0beff0c7e003a8bdbe17c5c761be4d4a79965f35a39139037afa7148e62
Python
7,401
203
from __future__ import annotations from tqdm import tqdm import numpy as np from spyne.core.spines.analysis.timeseries.timeseries import ( background, dFF, get_timestamps, z_score) def collect_timeseries( dataset, spines_data: list, metadata: dict, dendrites_masks: list, background_dilation_d...
420b1020392f3fbc71cb7156ab2a820f4a3a2bf2b6c97c306f6d8045e87f3b35
Python
7,406
206
"""Tests for `navis.sholl_analysis`, in particular the handling of `center`. `center` accepts several forms - the "centermass"/"root"/"soma" presets, a node ID or an x/y/z coordinate. The dispatch used to resolve "centermass" into a coordinate array *before* the remaining branches compared `center` against the string ...
eb75be482649bb7dbfe36b096fe2dd94f080f417941a0c58c6816259faa51f97
Python
7,406
260
""" @Article{li2014multiplicative, author = {Li, Chunming and Gore, John C and Davatzikos, Christos}, title = {Multiplicative intrinsic component optimization (MICO) for MRI bias field estimation and tissue segmentation}, journal = {Magnetic resonance imaging}, year = {2014}, volume = {32}, ...
27315eab366c84df0d0cfb7f828cd807c76c129908ebc8736eca9a794aabac52
Python
7,411
149
############################################################################ # Copyright (c) 2022-2026 University of Helsinki # Copyright (c) 2020-2022 Saint Petersburg State University # # All Rights Reserved # See file LICENSE for details. ############################################################################ ...
32615e6ac5bbaabeb727dd449ae57c779bb4df32ddcbe0c4860cd7a29d9415b4
Python
7,419
229
""" Analyse stationary spike trains ## Functions - `interval_statistics()`: statistics and kde of interspike intervals. - `burst_fraction()`: burst fraction based on ISI distribution. - `serial_correlations()`: serial correlations of interspike intervals. - `vector_strength()`: vector strength of spike times relative...
714eb1b42635da02262340260925ad2dc421fa9e3c668918b079a9f383cd3d27
Python
7,426
186
# Copyright (c) Facebook, Inc. and its affiliates. import unittest from detectron2.layers import ShapeSpec from detectron2.modeling.mmdet_wrapper import MMDetBackbone, MMDetDetector try: import mmdet.models # noqa HAS_MMDET = True except ImportError: HAS_MMDET = False @unittest.skipIf(not HAS_MMDET, "...
c51153e8fd55b8eb7b4f256f11a2f14c975c196c8affc9ebd322e95a0290b854
Python
7,426
164
import os import pandas as pd import numpy as np from loguru import logger logger.info('Import OK') pd.set_option('display.max_columns', 500) def tmt_peptides(input_path, sample_names=None, pep_cols=[]): peptides = pd.read_table(input_path, sep='\t') logger.info( f'Imported peptides from {input_p...
1dca79f7454a574cbc1f812ec027151e479bf159266056e31817a99ae4b88a00
Python
7,434
233
import torch import torch.nn as nn from .meta.electrode_names import channels from .VisualTransforms import EEGScalpMap from .utils import Tab class R2Plus1D_Block(nn.Module): def __init__( self, in_ch, out_ch, k_t=3, k_s=3, stride_t=1, stride_s=1, ...
9c32b204d4cdf23eb3760ef8220b4fb21c27d6ae13077656f3d8e9574498e248
Python
7,440
218
"""Tests for the optimized `navis.graph.connecting_nodes`. The optimized implementation is checked against a frozen copy of the original implementation (`_connecting_nodes_old`) to prove identical results, except in the documented edge case (subset contains an ancestor of the branch-point LCA) where the new implementa...
4130760adbd39af282486cc845ec9de4bd0041c05b5a057bb56e44d4f071d1e4
Python
7,441
156
from __future__ import annotations from dataclasses import dataclass import numpy as np import pandas as pd from sklearn.impute import KNNImputer from sklearn.model_selection import GroupShuffleSplit from sklearn.preprocessing import OneHotEncoder, StandardScaler @dataclass class FittedPreprocessor: retained_va...
14143bdb4022e26d1dee91609d821600dbdc15425667e6376f5d40bae1a7cfd0
Python
7,442
231
from __future__ import annotations import re import sys from collections.abc import Container, Iterable, Iterator, Sequence from typing import ( Any, AnyStr, Generic, SupportsIndex, TypeVar, overload, ) from typing_extensions import Self, override _T = TypeVar("_T") _K = TypeVar("_K", bound="...
e0c87457caeed5d92e7577da3f4a08d36b795dbf5b10c4047a09e4f0549c74c0
Python
7,454
182
"""Environment checks. Most TAPA failures in the wild have been missing external programs rather than bugs in the pipeline: MFA unable to find its OpenFst helpers, Dr.VOT unable to find sox or a working Praat. Each surfaced minutes into a run, as a confusing traceback or — worse — as a silent fallback to a cruder meth...
44b6d16eb91babf464fef54c5f3203dc8f4318df8ab31ea94652239c326c5954
Python
7,455
224
""" Stage 3: apply curated merges + finalize, per session. Reads batch_sort/stage2/stage2_analyzer.zarr + curation_config.json, applies the selected merges, and writes batch_sort/stage3/analyzer_final.zarr. Usage: python -m batch_process.stage3_merge <session_folder> [<session_folder> ...] [--force] """ ...
935e61b19796edd93b7e3822f64acb3ec7d00a9da9a1ab18999886798f0db7fa
Python
7,469
247
# This code is part of OpenFE and is licensed under the MIT license. # For details, see https://github.com/OpenFreeEnergy/openfe """ Restraint Geometry classes TODO ---- * Add relevant duecredit entries. """ from typing import Iterable, Optional import MDAnalysis as mda from openff.units import Quantity, unit from r...
3ea8f54b35f4053652924277ae2759c621d27a30727da965b5f8493aa3ba544d
Python
7,477
197
############################################################################ # Copyright (c) 2025-2026 University of Helsinki # All Rights Reserved # See file LICENSE for details. ############################################################################ import pytest from isoquant_lib.barcode_calling.indexers impor...
3345b4f80ef9cebe4ebbb28ae37b787575f4d6ebea74f0fd1c932a35481759e0
Python
7,478
286
import torch from torch import nn as nn class BCEDiceLoss(nn.Module): """ Combines Binary Cross-Entropy Loss and Dice Loss. Parameters ---------- alpha : float Weight for the Binary Cross-Entropy Loss component. beta : float Weight for the Dice Loss component. """ def ...
984289513aac8ab4ade88146039222a4aad75046a4a896c74527ef0891933778
Python
7,486
171
#!/usr/bin/env python3 # Copyright 2004-present Facebook. All Rights Reserved. import copy import numpy as np from typing import Dict import torch from scipy.optimize import linear_sum_assignment from detectron2.config import configurable from detectron2.structures import Boxes, Instances from ..config.config import ...
0aaed5930a6c3ed48e0bee973b1e8358661745d55cd28f9abc1a8eff46d438a2
Python
7,488
219
from tqdm import tqdm import numpy as np import calcium_event_classifier as cec from sklearn.neighbors import KernelDensity from scipy.signal import find_peaks def detect_calcium_events( config: dict, zscores: np.ndarray, dFF: np.ndarray, ) -> np.ndarray: """ Detect calcium events in s...
c5bcff01a3f64f6d3b8d29a8ec292db397f3498fb59878e3374899c15398f764
Python
7,500
199
# Copyright (c) Facebook, Inc. and its affiliates. import contextlib import io import itertools import json import logging import numpy as np import os import tempfile from collections import OrderedDict from typing import Optional from PIL import Image from tabulate import tabulate from detectron2.data import Metadat...
80d42571dd728e6ae39e6da8ec79644e985430eeef77f58c9c8c0fcd3a1b592e
Python
7,501
215
# # Copyright (c) 2025 10X Genomics, Inc. All rights reserved. # """Call cell types based on Satija-Lab's Azimuth.""" import csv import itertools import json import math from dataclasses import asdict, dataclass import martian import numpy as np import cellranger.matrix as cr_matrix from cellranger.cell_typing.azim...
ea096e56567c4ab9be8594bf4b75af79c1facf52f58785adb791e0d02c3cfca4
Python
7,502
164
import os import numpy as np import matplotlib.pyplot as plt from matplotlib.lines import Line2D from tristan_pipeline.utils.plotting_utils import * from tristan_pipeline.utils.analysis_utils import * from tristan_pipeline.io.params import * from nilearn.glm import threshold_stats_img space = "T1w" mocos_ = ["Servo o...
a2624fb519a16a984823ed3d650eb983b5c8e05713132e46eab3306e51dd4b01
Python
7,504
202
# 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...
02712da6f0824e8c0a7ee63b4cc09b788205e9e837c8e63e57d10e3e53a1f54f
Python
7,509
204
"""Abstract Base class for building cell-based spatial environments. DiscreteSpace provides the core functionality needed by all cell-based spaces: - Cell creation and tracking - Agent-cell relationship management - Property Layer support - Random selection capabilities - Capacity management This serves as the founda...
09497486df1702f33f5813409ac44ef37a2e45c18167bfe6a1fd762537305824
Python
7,512
210
# Copyright (c) Facebook, Inc. and its affiliates. import os import pickle import sys import unittest from functools import partial import torch from iopath.common.file_io import LazyPath from detectron2 import model_zoo from detectron2.config import get_cfg, instantiate from detectron2.data import ( DatasetCatal...
b8626ab433c09ffa6df9d49869420d497ce93bdb2c5cc084e36bb73c20796383
Python
7,513
184
""" Augmenting Neurons ================== <!-- difficulty: intermediate --> Augment neuron training sets with realistic perturbations for robust models. The `navis.ml` module provides a set of geometric and sampling augmentations. Every one of them: - accepts a [`navis.Skeleton`][], [`navis.Mesh`][], [`navis.Dotprop...
571d593d5732e9536d8bd2638783d577e903167fee84b6e218cfd9d9c09358b6
Python
7,515
215
# 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...
7945d89eaa90929f211e00da8f4febea960c0f91174284680cf301affda891cb
Python
7,518
161
""" Volumes ======= <!-- difficulty: intermediate --> Put a neuropil around your neurons without losing sight of them. A [`Volume`][navis.Volume] in 3D has exactly one hard problem: it is a closed shell, and you want to see what is inside it. Everything below is about that trade-off - and about the fact that a real r...
1db5efa4e7dd3d10549fef8ae3e6a6092551991404bc9f73d1e419978cf3252d
Python
7,534
200
# This code is part of OpenFE and is licensed under the MIT license. # For details, see https://github.com/OpenFreeEnergy/openfe import gzip import itertools import json from unittest import mock import gufe import numpy as np import pytest from openff.units import unit as offunit import openfe from openfe.protocols ...
8d0972dd85bd76095b76315b184b2dbd90686464f509bc452bad9fc667513d2c
Python
7,536
199
""" The MICrONS Datasets ==================== <!-- difficulty: intermediate --> Fetch and explore neurons from the MICrONS EM datasets. The [Allen Institute for Brain Science](https://alleninstitute.org/) in collaboration with Princeton University, and Baylor College of Medicine released two large connectomics datase...
d026bc3b44a803d26d6b494a23ec4c15d57ea4c8725e9614a3ae474466831fc3
Python
7,539
303
"""Standardization for multi-response social risk and comorbidity fields.""" import pandas as pd SOCIAL_RISK_MAP = { "Current smoker": ( "Current smoker", "keep", "", ), "Documented MDR contact": ( "Documented MDR contact", "keep", "", ), "Homeless"...
5299855e5ed0fd768ee8fb3ad90e080afe59e5dac6434e3829fdd93bf57b7706
Python
7,548
214
import glob import os import re import matplotlib.pyplot as plt import numpy as np import pandas as pd import psignifit as ps def _binomial_log_likelihood(k, n, p): p = np.clip(np.asarray(p, dtype=float), 1e-12, 1 - 1e-12) k = np.asarray(k, dtype=float) n = np.asarray(n, dtype=float) return float(np....
49dbc509a712c4184adf438a1fa7e9a6be159ec7412dae4a26416c16976d2d02
Python
7,555
179
#!/usr/bin/env python # Copyright 2016-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 obt...
548354828376b9d8a7db76cdb8dcb356b833552c20444ef586c74b81936d78ea
Python
7,556
232
# Script that makes use of more advanced feature selection techniques # by Alberto Tonda, 2017 import copy import datetime import logging import numpy as np import os import sys import pandas as pd from sklearn.ensemble import AdaBoostClassifier from sklearn.ensemble import BaggingClassifier from sklearn.ensemble im...
9fac0ab37e696e80b77a4e3befaf6a695f3a8884dec73c996874f6c7d17877b9
Python
7,562
82
from tristan_pipeline.io.params import * import glob import nibabel as nib #from nilearn.image import mean_img def load_rawdata(RAW_PATH, subj, ses,moco): RFUNC_PATH = glob.glob(os.path.join(RAW_PATH, f'sub-{subj:02}', f'ses-{ses}', 'func', f'sub-{subj:02}_ses-{ses}*_acq-{moco}_bold.nii')) RFMAP_PATH = glob.g...
b0b8493cd44a2ddd1e75cd6e7574c7e6be85f5628edade51564ed67c8aaa58fa
Python
7,568
226
import torch import wandb import matplotlib.pyplot as plt import seaborn as sns from torchmetrics import Metric def log_confusion_matrix_advanced( conf_matrix, class_names=None, step=None, normalize=False, title="Confusion Matrix", split="train", cmap=sns.color_palette("YlOrRd", as_cmap=Tr...
4c0f59b6ba60d25f501facb28ecfc7544cf9b1521d3f014ec5f37339643816e6
Python
7,570
265
""" Molecular featurisation for VAE models. Converts RDKit molecule objects into the flat adjacency/feature tensor representation consumed by the VAE. Deliberately free of ``torch_geometric`` so that generation work never pulls in the GNN stack. """ import logging from typing import Any, Dict, List, Optional, Tuple i...
e2629991e7b56b78d2d51261bf9888da4b6881bcf507ed5230301f4bf9d2b0ac
Python
7,572
202
# Copyright (c) Facebook, Inc. and its affiliates. import copy import io import logging import numpy as np from typing import List import onnx import torch from caffe2.proto import caffe2_pb2 from caffe2.python import core from caffe2.python.onnx.backend import Caffe2Backend from tabulate import tabulate from termcolo...
b88a8c7305bd4967041c69fd1c5c5c6f586cf7c6a0490caff5eb72260c0bbcff
Python
7,584
229
from functools import partial import logging import multiprocessing as mp import os import pandas as pd from pathlib import Path import re from tqdm import tqdm from typing import Optional logger = logging.getLogger("balanced_interpolation_ds") def filter_seqs( recs: pd.DataFrame, min_len: Optional[float] =...
7d037d5013a68c72afe61c7fa9d49493bdfe88057b100a217beeec7fe2581116
Python
7,585
200
import logging from enum import Enum from functools import partial from os import PathLike from pathlib import Path from typing import Generator, Optional, Sequence, Tuple, Union import numpy as np import pandas as pd from scipy.ndimage import distance_transform_edt from scipy.spatial.distance import pdist, squareform...
93616064f89c4381d33f4983383389b33d7cc33eb560ba01b5982da33b8015fa
Python
7,590
249
# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # http://www.sphinx-doc.org/en/master/config # -- Path setup -------------------------------------------------------------- # If extensions (or module...
2b69d4c74268c2b5046547cdb20ada5620bc28bdb99b2b47e49ec13374cd5583
Python
7,593
201
import os import numpy as np import pandas as pd import umap import matplotlib.pyplot as plt import anndata as ad import scanpy as sc import scvelo as scv import cellrank as cr import scanpy.external as sce from scipy.io import mmwrite, mmread import statsmodels.api as sm np.random.seed(42) # peak-gene linkage matrix...
01a7870e7a64a68cb3c6b8be8f4ff25f42282531e7ab0af74520edba554f1d13
Python
7,601
200
from __future__ import annotations import logging from pathlib import Path from types import SimpleNamespace import uuid from rdkit import Chem from src.utils.models import MolecularRecord from src.workflow import pipeline class _FakeSource: def __init__(self, settings: dict) -> None: self.settings = s...
05f208174c260b487555f6eda00bb512e9809e99e7171e6161c113d744bf0692
Python
7,602
202
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Plot Hide-the-Label mean steps per optimizer from a results JSON. Supports two structures: - optimizer_stats: { OPT: { mean_steps, std_steps, success_rate, ... }, ... } - tournament/competitions: competitions[*].optimizer_results[OPT].steps_to_target Usage: Set the...
514d2d5e81a5a95bbf93cd0b182274e3a84a30c1acb4224aa7244c616164b764
Python
7,609
195
#!/usr/bin/env python # Copyright 2016-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 obt...
da0b603280938443165515298ecd00a56214846ddd99d104ccef5c9824663a85
Python
7,615
201
import os import sys import numpy as np import torch as tc import torch.nn as nn from sklearn.mixture import GaussianMixture as GMM from argparse import Namespace sys.path.append("../..") from src.rnn.models import linear_observation_model, identity_observation_model, PLRNN, clshPLRNN, shPLRNN class RNN_cont_Model(nn...
1a176f13991fbdc6291829ddfb72527453f3f315a25804c3dcb1ba9970b972cb
Python
7,617
176
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. import copy import json import os from collections import defaultdict # This mapping is extracted from the official LVIS mapping: # https://github.com/lvis-dataset/lvis-api/blob/master/data/coco_to_synset.json COCO_SYNSE...
55816d89c6958b45bea5ecbf6d6e5e007ca5db84e07a7dc1e4a50762e3b1e691
Python
7,619
209
# Copyright (c) Facebook, Inc. and its affiliates. import itertools import json import numpy as np import os import torch from pycocotools.cocoeval import COCOeval, maskUtils from detectron2.structures import BoxMode, RotatedBoxes, pairwise_iou_rotated from detectron2.utils.file_io import PathManager from .coco_evalu...
86df3e654c4d6e35e81813b50a3f522ba15237834211cca93dd33793762137ce
Python
7,631
191
from dataclasses import dataclass from pathlib import Path from typing import Union from toolbox.utils import simulation_params as simp, screen_params as scp, load_param_from_config @dataclass class Entry: """This is a data class to hold the entry data structure Attributes ---------- me...
37e0251bf24b517e6989671127d20ac320017e0a76d205c64660d81e55ff74aa
Python
7,636
175
# Copyright (c) Facebook, Inc. and its affiliates. import numpy as np import unittest import torch from detectron2.layers import DeformConv, ModulatedDeformConv from detectron2.utils.env import TORCH_VERSION @unittest.skipIf( TORCH_VERSION == (1, 8) and torch.cuda.is_available(), "This test fails under cuda1...
db688869e1bc73809d1faa3c3412225f9eb2a71ee80eb6f95b700d41ac42e0ed
Python
7,641
155
# Copyright (c) Facebook, Inc. and its affiliates. # Reference: https://github.com/bowenc0221/panoptic-deeplab/blob/aa934324b55a34ce95fea143aea1cb7a6dbe04bd/segmentation/data/transforms/target_transforms.py#L11 # noqa import numpy as np import torch class PanopticDeepLabTargetGenerator: """ Generates trainin...
b4b130c21bafbd1b48b77c7dd72c65704616c31037129681d19069fbd62d84a6
Python
7,645
198
#!/usr/bin/env python # Copyright 2016-2023 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...
ff9e89856a5f094d6ff21c50df3faa5f1624981a46fed22212066325b9957bcb
Python
7,654
209
""" Sequence embedding models for protein representation. This module provides wrappers for protein language models (ESM-2) used to generate sequence embeddings for stoichiometry prediction. """ from abc import ABC, abstractmethod from typing import List, Optional, Tuple, Union import torch from loguru import logger...
65bf3e9dd89ceb20d610981520a7a6340e5440b20b0112fe322772e06c9e1418
Python
7,665
276
""" Utility functions for affinity/similarity matrices. """ # Author: Oualid Benkarim <oualid.benkarim@mcgill.ca> # License: BSD 3 clause import numpy as np from scipy import sparse as ssp def is_symmetric(x, tol=1E-10): """Check if input is symmetric. Parameters ---------- x : 2D ndarray or spars...
f054187e8a6336675d1ca2d436aaa96933b37c296f2c9c8746ef5350404b5e45
Python
7,671
206
import torch import torch.nn as nn import numpy as np import modules from util import aa_sequences_to_padded_onehot, pad_feature_matrices device = torch.device("cuda" if torch.cuda.is_available() else "cpu") class RINAMI(nn.Module): def __init__( self, device=device, dropout=0.1, ...
1eb3f7faec5e2b2d0343493391b4e28915fca7a623ae7beed97e1134b4111d69
Python
7,673
241
import json import shutil from importlib import resources from unittest import mock import numpy as np import pytest from click.testing import CliRunner from gufe import AlchemicalNetwork, SmallMoleculeComponent, SolventComponent from gufe.tokenization import JSON_HANDLER from openff.utilities.testing import skip_if_m...
69fdf34aa546679f2193357165d74d9fd58b77af2edcc7efd87ec099a28a990c
Python
7,675
188
""" core/spikes.py -------------- Spike-level processing: filtering, binning, ISI metrics. All functions take plain numpy arrays or dicts — no file I/O here. """ import numpy as np import pandas as pd from typing import Dict # ── Active-electrode filter ──────────────────────────────────────────────────── def filter...