sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
f4e872478fa658fe19e632db6ac3ac329ab3bdfb3b6ef2c1ac1b170a94a110b6
Python
20,162
619
import json from collections.abc import Collection from langgraph.graph import StateGraph, START, END from langchain_openai import ChatOpenAI from langgraph.checkpoint.memory import MemorySaver from langgraph.prebuilt import ToolNode from chemgraph.tools.ase_tools import ( run_ase, extract_output_json, ) from ...
7fa9917830e9e72a53ff571acfafc6a461b4a641bd7fc0c797ac636670ec26e4
Python
20,166
418
#!/usr/bin/env python # coding: utf-8 import os import random import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from torch.utils.data import DataLoader, Dataset from torch_geometric.nn import GCNConv from tqdm import tqdm from sklearn.model_selection import StratifiedKFold from skl...
eb614e495fedb7316522b716d7f3a235b05e8814151adeb918a20097dcf7b8a1
Python
20,172
601
from collections.abc import Callable, Iterable, Sequence from contextlib import nullcontext from dataclasses import dataclass from typing import ( TYPE_CHECKING, Any, ) import torch from torch import autocast, nn from torch.nn.utils import clip_grad_norm_ from torch.optim.optimizer import Optimizer from eir.d...
50b1b01031702913055faa64c3fcdd629748f667c4ccfff2ddac92b3ef4ad02f
Python
20,174
472
alg_name = 'graph_saint' import os os.environ["OMP_NUM_THREADS"] = "2" # export OMP_NUM_THREADS=1 os.environ["OPENBLAS_NUM_THREADS"] = "2" # export OPENBLAS_NUM_THREADS=1 os.environ["MKL_NUM_THREADS"] = "2" # export MKL_NUM_THREADS=1 os.environ["VECLIB_MAXIMUM_THREADS"] = "2" # export VECLIB_MAXIMUM_THREADS=1 os....
ca8750723269cd56801e45c5d1fe801847ae5b070fb6d94c8eba9a25e7089ba7
Python
20,175
467
"""Test the run progress model and its display. Run from the repo root:: uv run python python/test_progress.py The clock is injected, so every timing assertion here is exact rather than flaky. What matters is not that a number appears but that it is *right*: an estimate that is confidently wrong is worse than no...
1b061552f898f4d0ba7d58c913d3b938e58d2e9d921e5a76d2a782f2774cbdc2
Python
20,180
588
import os import re import pickle import inspect import numpy as np import pandas as pd import importlib_resources def load_timeseries(path=None): """ Load time series data from a file. Supported file formats are: .pkl, .txt, .npy, .mat, and .tsv Parameters ---------- path : string pat...
a5fcb788278db788b04d7ccc7c557e9a98dafa612247059ec00c16ba9f0c8714
Python
20,192
485
import json import itertools from pathlib import Path from typing import Dict, List, Tuple, Union from magicgui.widgets import FunctionGui import matplotlib.pyplot as plt import pandas as pd import seaborn as sns from matplotlib.backends.backend_qt5agg import FigureCanvas from matplotlib.figure import Figure import mat...
776386c8daf0c0e40ced4fc2eaf4e61fa557c90d6b87e220f634cc40ddf7b38c
Python
20,208
506
from typing import Any, Dict, Tuple import numpy as np import torch from torch import Tensor from torch_geometric.data import Data from torch_geometric.data.datapipes import functional_transform from torch_geometric.transforms import BaseTransform from torch_geometric.utils import ( add_self_loops, coalesce, ...
876160b1427c8073dc1c88e45e21ba97e8f7a4f526ddaea4e327326deec02808
Python
20,214
493
import torch import numpy as np from torch import nn, einsum from einops import rearrange, repeat from einops.layers.torch import Rearrange from typing import Union, List from timm.layers import trunc_normal_ class CyclicShift3D(nn.Module): def __init__(self, displacement): super().__init__() asse...
83e9c183b810e9e86887751004929c96a9ccbed1b0111e759a11f23de846f80b
Python
20,223
373
import tempfile import unittest from pathlib import Path import numpy as np from dtiplayground.dmri.preprocessing import qc_metrics, batch_report def _gradients(n_dirs=30, n_b0=5, bval=1000.0, seed=0): rng = np.random.default_rng(seed) dirs = rng.normal(size=(n_dirs, 3)) dirs /= np.linalg.norm(dirs, axi...
49db3af674c2f74c19ff6c3b08c42741e582e18e04c0d5e7ea8ceaefa929e6b7
Python
20,225
401
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Feb 1 09:16:38 2024 @author: rl05 Perform cluster-based permutation tests on ROI data """ import os import os.path as op import sys import pickle import numpy as np import math import matplotlib.pyplot as plt from mne import read_source_estimate fr...
7bd3270b394cd0d89479e43d9e4425d91eb7ccfc3dd9ecfc044ad5e6ab144445
Python
20,254
427
import numpy as np from scipy.signal import butter, filtfilt, hilbert, iirnotch, resample from sklearn.preprocessing import StandardScaler from scipy.interpolate import interp1d from scipy.stats import sem, zscore from General import * from Utilities_and_Loading import * def perform_BP_all_data(all_data, global_param...
97456e82fd7ec492961f540e75c771ff650b4bbdcad4ddd03067c44d8a6b8fe4
Python
20,254
437
from __future__ import annotations import csv import os.path import pickle import datetime from tqdm import tqdm from metaphlan.utils.merge_metaphlan_tables import merge from .utilities import run_cmd, ReadsData, check_conda_qiime2 import json import shutil CONDA_PREFIX = os.environ.get("CONDA_PREFIX", None) def ch...
248c36e128571180ad0d973e32ef36dfb2914b54d794cb3bbf7f2549f5121bd1
Python
20,262
461
"""Gabor-filter entropy features for arbitrary image sets. This is a standalone Python port of the descriptor behind the GaborFilterEntropy4x4Cosine model from the EntropyReanalysis MATLAB scripts. The default settings match that model: 256x256 grayscale images, six octave frequency bands [1, 2, 4, 8, 16, 32], si...
f41fb9c98002f3d36ea17a9715a911ce186b3d432d4b4bee73e1604a103cda96
Python
20,265
621
"""Train an ABMIL model for classification. The inputs to the model are bags of embedded histology patches. The outputs of the model are classification predictions. """ from __future__ import annotations import dataclasses import json import math import random import shutil from pathlib import Path from typing impo...
3750b13cd665d68dab6a5f9733957c02c9cf3c0ab188059a9152a5d9a9ada4a3
Python
20,267
564
from typing import List, Tuple, Iterable import math import torch import torch.nn.functional as F from torchvision.transforms import InterpolationMode import torchvision.transforms.functional as T import numpy as np def array(torch_tensor, permute=True): """ Converts a torch.Tensor to a numpy array on the CP...
4ef57965680edb7703072f703d1e58e0c2f0a99d2dd97dd758a7b4cfd014cbb3
Python
20,268
398
import pandas as pd import logging, os, sys, yaml from collections import defaultdict novascope_scripts = os.path.dirname(os.path.abspath(__file__)) sys.path.append(novascope_scripts) from bricks import check_input, check_path, create_dict, get_last5_from_md5, create_symlink, create_dirs_and_get_paths from bricks impo...
e5b6a4743a469af6cbba77cd88aa2a40aa479ef5466069a419ae6bd67120cc1f
Python
20,271
623
#!/usr/bin/env python """ Interface to Point Grey's PySpin Python module. Tested with "Spinnaker 1.19 for Python 2 and 3 - Windows (64-bit)". Note: As currently written this is designed to work with 12 bit cameras. See onImageEvent() in SpinImageEventHandler class. Hazen 01/19 """ import numpy import os impor...
5790bc81690d6a821764de35d04d110e7b584890e189aee153834c0065df5b04
Python
20,293
578
import numpy as np from .parameter import Parameter # TODO: add examples and tests # (for both Phi and Parameter) # TODO: TF compatibility functions? during fitting, values would have to exist # as TF primitives, but need to be able to translate to/from # TF and NEMS representations. class Phi: ...
07394b4c85c31282fc655b50d4f6cce044c88d78ffd96e98af3f687d3087fc2e
Python
20,297
486
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Filtering of a tractogram based on any combination of conditions involving a ROI (ex: keep streamlines whose endoints are inside the ROI, exclude streamlines not entirely included in a ROI, etc.) See also: - scil_tractogram_detect_loops - scil_tractogram_fil...
c52ac40685294d941837cf878ed1323e21018dd4ddd5737e64fd5635d978a761
Python
20,316
360
import pandas as pd import numpy as np import torch import argparse def convert_to_binary(value): return 1 if value > 0 else 0 def modify_node_index(index_value,lncRNA_size,miRNA_size,drug_size): if index_value < lncRNA_size: return index_value elif lncRNA_size <= index_value < (lncRNA_...
a609dc4263197d97887d642ca44aaea1aec57e65a838924faaf14794d8ef58c3
Python
20,320
498
#!/usr/bin/python # ## @file # # An xml parser class that takes a sequence recipe xml file and converts it to # a flat sequence file that can be read by Dave # # Jeffrey Moffitt # 1/5/14 # 9/4/14: Updated to Dave4 format # jeffmoffitt@gmail.com # # # Import # import os import sys import traceback from xml.etree impo...
1b00fc8d8277920de96b3d1eb8cf762a690115cb60c0925ef9958875229f4253
Python
20,329
508
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math from typing import Dict, Optional, Tuple import torch import torch.nn.functional as F from torch import Tensor, nn from torch.nn ...
4cb601e03ab03e3000c812661ff32f8cf3ff6b5ea236f9f6a1b3978c557c265f
Python
20,334
434
#!/usr/bin/env python3 """ BehaveAI Launcher (project-aware) - Projects are stored in ./projects/ - Each project is a subdirectory containing: - BehaveAI_settings.ini - clips/ input/ output/ models/ yamls/ (created by the launcher) - Launches scripts with the project's directory as cwd and passes the project path a...
ba88bfa9f8fc4cf44dc962313790af7f901d2c28c76161f684349dc9133149bb
Python
20,336
527
# Copyright 2024 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
a225e445ce002fef5131cc7f2480e7d5abcf8c6e46580c5726f6c9e23cee7641
Python
20,343
451
import os import torch import math import yaml import warnings import argparse import numpy as np import pandas as pd import torch.nn.functional as F import scipy.spatial as spa from tqdm import tqdm from torch_geometric.data import Data from scipy.special import softmax from Bio.PDB import PDBParser, ShrakeRupley from...
7999bb8f0adf5f576f702b64f75279491c5e143dd4f6e8df17675d9c85b00886
Python
20,349
544
# -*- coding: utf-8 -*- """ Created on Sun Oct 17 16:50:29 2021 @author: axthi """ import gc import copy import nibabel as nib import numpy as np import os from scipy import ndimage from scipy.ndimage.filters import uniform_filter import scipy.ndimage.morphology as mrph from simnibs import mesh_io, sim_struct, __ver...
894864b5c63f8e81df0f1a6d3f89a0da32ce89d61c17772ca756f7061ff00630
Python
20,359
440
""" Supplementary Information Figure S3: Phase-cycled bSSFP profiles - SpinWalk simulations vs. in vivo data 2x4 subplot layout comparing bSSFP magnitude and phase profiles across phase cycling angles: - Column A: 3T SpinWalk simulation results for different fiber orientations (θ = 0°, 30°, 60°, 90°) - Column B: 9.4T ...
82b8a7dc912e832b0c4663940e528d8dad63823e329090a0ff2b9ec57721ccfe
Python
20,365
561
# -*- coding: utf-8 -*- """Full cortex reconstruction The purpose of the following workflow is to compute the segmentation for hires MP2RAGE (or MEMPRAGE) data and bring the resulting surface data of the cortical boundaries into a regular grid representation. The script is divided into five parts. Single steps of of e...
3d7481d3767c026a969adf362c12e099799ecc13d06cf22dd11996bd9512d1f9
Python
20,366
443
import warnings from pprint import pprint import datajoint as dj import pandas as pd from djaddon import hdf5 try: from pupil_tracking import PupilTracker except ImportError: warnings.warn("Failed to import pupil_tacking library. You won't be able to populate trk.EyeFrame") schema = dj.schema('pipeline_pupi...
ccacdb5b77b49666394f3f68e964572b53835826dc3c924204415a22cf84ed2a
Python
20,371
624
# -*- coding: utf-8 -*- """Time-series manipulation.""" import os from math import prod import nibabel as nb import numpy as np from nilearn.signal import clean from numpy.fft import fft, ifft from scipy.interpolate import InterpolatedUnivariateSpline as Interp from scipy.ndimage import gaussian_filter from ..io.fil...
a1440a88e7b25c0dbabb0845d9381388fa1ff9bacffc6a68daf17b8c58502103
Python
20,380
646
""" Plot the probability of switching as a function of the outcome and player identity for one session, based on trial_info.csv """ from scipy.stats import ttest_ind import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns from utils.plots import beutify from copy import deepcopy ...
54319879671576fb9e39dc5575387c5cf6a88e329b121ad6e6998d90798c7145
Python
20,383
532
import gc import torch import numpy as np import cv2 from torch.nn import functional as F from os import listdir, makedirs, getcwd from os.path import join, exists, isfile, isdir, basename from glob import glob from ipywidgets import interact, widgets, FileUpload from IPython.display import display from matplotlib impo...
3c0f13b52a84e271580d71e9387e1a5094880ea1260250ac4805744bf89321a6
Python
20,393
525
#!/usr/bin/env python """ HAL interface to National Instruments cards. Hazen 04/17 """ import numpy import storm_control.hal4000.halLib.halMessage as halMessage import storm_control.sc_hardware.baseClasses.daqModule as daqModule import storm_control.sc_hardware.nationalInstruments.nicontrol as nicontrol import stor...
027e1555b9e6d2770bb7eeef4bc4d93e399411e9c21124d6601a87161f3d7aa7
Python
20,395
617
# laminar_rs/gradients.py """ Gradient-based analyses and laminar (dis)similarity metrics. This module provides: - BrainSpace-based gradient estimation from connectivity / affinity matrices - Inter-areal and intra-areal laminar dissimilarity measures - Clustering of eigenvectors with sign-invariant distances - Cosine-...
0b9b0cb492aa4fff0dd788e43298a6b385e77b4eb5e79b566082dc66df55d65d
Python
20,418
504
"""Tests for mcmlnet.utils.rescaling module.""" import copy import numpy as np import pytest import torch from mcmlnet.utils.rescaling import DataRescaler class TestDataRescaler: """Test cases for DataRescaler class.""" def setup_method(self) -> None: """Setup common variables for tests.""" ...
8a8286f7bf44394d2f98621be89c6213097375f41b5cc8140373dba5c10808ca
Python
20,428
503
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import csv import json import logging import math import os from itertools import combinations import matplotlib.pyplot as plt import numpy as np class data_for_stat(object): """ Method 'init' in the name will initialise argument of the object Method 'get'...
8d30fb06b435fcb848def7c18a9d31efe6bb9b148f5e9e4ec1e8f08dbcfd2025
Python
20,429
434
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license """ Check a model's accuracy on a test or val split of a dataset. Usage: $ yolo val model=yolo26n.pt data=coco8.yaml imgsz=640 Usage - formats: $ yolo val model=yolo26n.pt # PyTorch yolo26n.torchscript ...
f08dab011c475cb1221d8c1711691d82faa1f4a0de6feb113a81a65bc43b41c2
Python
20,430
356
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license """ Module for YOLO model metadata. This module stores detailed metadata for various YOLO models including authors, organizations, publication dates, arXiv links, GitHub repositories, documentation URLs, and performance metrics. FLOPs values mirror ea...
cc36dd45882a99833a85a43638c110144d278e63237463c52a172c2599e32053
Python
20,444
526
# This file is part of connectome-manipulator. # # SPDX-License-Identifier: Apache-2.0 # Copyright (c) 2024 Blue Brain Project/EPFL """Main module for connectome manipulations: - Loads a SONATA connectome using SNAP - Applies manipulation(s) to the connectome, as specified by the manipulation config dict - Writes bac...
2b3c56c62ccb6dc0813da2af608c54f842e624d12415b9cb2695a1d74b7141d5
Python
20,445
502
#!/usr/bin/python # ## @file # # An xml parser class that takes a sequence recipe xml file and converts it to # a flat sequence file that can be read by Dave # # Jeffrey Moffitt # 1/5/14 # 9/4/14: Updated to Dave4 format # jeffmoffitt@gmail.com # # # Import # import os import sys import traceback from xml.etree impo...
083bb17b9ee0f4d58fe9916317e55b1a91ef4726a329b5b44faafcdc2c85a293
Python
20,462
646
import io import numpy as np import pytest import xml.etree.ElementTree as ET from pathlib import Path from aicspylibczi import CziFile, remote_reads_available from _aicspylibczi import ( PylibCZI_CDimCoordinatesOverspecifiedException, PylibCZI_RegionSelectionException, ) @pytest.mark.parametrize( "as_s...
c1237c453fd490a59f149ae49fa8c2d439b14fb5ffc19422699dc6f7302990fc
Python
20,465
509
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license from __future__ import annotations import argparse import time from collections import defaultdict from urllib.parse import urlparse import cv2 import numpy as np import torch from transformers import AutoModel, AutoProcessor from ultralytics impor...
2e9d02cd73cfab278a1b4ae5580bacffadcf612115bad04ce3aaab105b4ddf17
Python
20,471
568
# -*- coding: utf-8 -*- """ Created on Sat Feb 13 19:00:43 2016 @author: ajaver """ import collections import os import numpy as np import pandas as pd import tables from scipy.ndimage.filters import median_filter, minimum_filter, maximum_filter from tierpsy.analysis.int_ske_orient.checkFinalOrientation import check...
6fd2d004123327f182701f03116784f94165e8ee1f217938654dcd43824461fb
Python
20,484
590
r''' The nanonis_programming_interface class initializes a socket connection to Nanonis, allowing the user to send commands to Nanonis through a TCP/IP connection. ''' import _thread as thread import atexit import socket import struct import time # Defines data types and their sizes in bytes datatype_dict = {'int':'...
7cf6ae4542e6e882c410f26a280a7d31ea7af008a834f9c855924472b4751e6b
Python
20,485
516
import argparse import os import shutil import sys import time import warnings from random import sample import numpy as np import torch import torch.nn as nn import torch.optim as optim from sklearn import metrics from torch.autograd import Variable from torch.optim.lr_scheduler import MultiStepLR from utilities.dat...
1efe0f318bb1de1006a16f571be8cf525d1969411c1a7aeae8f6caa35fa055a2
Python
20,488
543
import torch import torch.nn as nn import torch.nn.functional as F import torchvision import numpy as np import random from ._builder import build_model_with_cfg from ._manipulate import checkpoint_seq from ._registry import register_model, generate_default_cfgs # -------------------------------------------------- # ...
bb88827d8cab9a1a92438483ed97b5b3f4a052fa10f935750b5dffb04a2abdde
Python
20,517
566
import numpy as np import polars as pl import scipy from scipy.interpolate import interp1d from scipy.ndimage import gaussian_filter1d from tqdm import trange from typing import NamedTuple, Callable from neuralib.locomotion import running_mask1d from neuralib.suite2p import ( Suite2PResult, get_neuron_signal, ...
4fd554e1eec01c079a17bd0f2f542d0991490cb5ad10a3a6636889109324a393
Python
20,532
483
import numpy as np from PySide6 import QtGui, QtWidgets, QtCore from PySide6.QtWidgets import QWidget, QMenuBar, QMainWindow, QVBoxLayout, QLabel, QHBoxLayout, QGridLayout, QPushButton, QCheckBox, QSlider, QTableWidget, QTableWidgetItem, QTabWidget, QGroupBox, QSpinBox, QFileDialog, QMessageBox, QComboBox from PySide6....
e8d5eea7b8d800b529a47ada6e8955677115c4f12c2eb353b3b030a329d30c6b
Python
20,542
542
""" InceptionNeXt implementation, paper: https://arxiv.org/abs/2303.16900 Some code is borrowed from timm: https://github.com/huggingface/pytorch-image-models """ from functools import partial import torch import torch.nn as nn from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD from timm.models.helpe...
e5562e421e21c2750b4a17fc5ebbd5d2664dcc79def5c7862f7eebd8795f0ceb
Python
20,565
480
import torch import torch.nn.functional as F from deepcardio.neuralop_core.models.base_model import BaseModel from deepcardio.neuralop_core.models.fno import FNO from deepcardio.neuralop_core.layers.embeddings import SinusoidalEmbedding2D from deepcardio.neuralop_core.layers.spectral_convolution import SpectralConv f...
de3fcf04d5e949c25997ed0351e64a8a02c3c3211aec03ce99fbbe6994c28192
Python
20,581
374
from brainvoice.data.estimates_loader_utils import load_estimate_labels, load_latent_variables_estimates import argparse import numpy as np from tqdm import tqdm import pandas as pd from sklearn.preprocessing import StandardScaler, RobustScaler from sklearn.linear_model import LogisticRegression from sklearn.m...
4ad9252c98bb7bc9c409ef42f06f65efebc700f00b6c2edf05cdedb11b8cddd1
Python
20,584
508
import sys import os import pandas as pd import pyreadr import torch import glob import functools import random import yaml import torch_geometric.transforms as T import torch.nn.functional as F from math import ceil from torch_geometric.data import InMemoryDataset, Data from torch_geometric.loader import DenseDataLoad...
10d7d57942e519498329b15d95ab16b3244e4b3a9513b576a34018ef3065ace5
Python
20,588
471
import torch import numpy as np import torchvision import torchvision.transforms as transforms from torch.utils.data import DataLoader, Subset import copy def dataset(config): ## Dataset transform = transforms.Compose([ transforms.ToTensor(), # ]) if config.train_task == "...
6691403b845a753c67bb7f9803eb8bf14b3ccb933e7d6651063e583325967c5c
Python
20,589
501
import json import itertools from pathlib import Path from typing import Dict, List, Tuple, Union from magicgui.widgets import FunctionGui import matplotlib.pyplot as plt import pandas as pd import seaborn as sns from matplotlib.backends.backend_qt5agg import FigureCanvas from matplotlib.figure import Figure import mat...
47a046e8da25c8ec760aea12bc986f9b44232ceb06b5caaaa30b0e18be80b579
Python
20,592
634
# by Shaoxuan Yuan at 2024/04/22 from __future__ import division, print_function import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.data class conv_block(nn.Module): """ Convolution Block """ def __init__(self, in_ch, out_ch): super(conv_block...
e5a3d7fd9342c02b4c0a1d531f2d5117bc3fc6596d1775674205d26cb6894d06
Python
20,622
645
""" This script makes the raster and histogram plot of two simultaneously recorded units. """ import sys import os sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import os import json import numpy as np import pandas as pd import matplotlib as mpl import matplotlib.pyplot as plt fro...
6d662d860338b299ab6bc84289f1940bfad8158547909d5b500246fb328e2236
Python
20,630
528
import pytest import json import numpy as np from unittest.mock import Mock, patch from stack_corr.correction import StackCorrector, correct_stack class TestStackCorrector: """Test the StackCorrector class.""" @pytest.fixture def mock_image_data(self): """Create mock image data for testing.""" ...
ea1f13021593b16c6e3154bf1b8a297a313ef02bbe11e8bc4df5e640e53dd709
Python
20,633
546
#!/usr/bin/env python3 """ Train DREAM-RNN models using the official @DREAM_paper implementation This script implements the exact DREAM-RNN architecture and training methodology from the @DREAM_paper tutorial notebooks for DeepSTARR data. """ import argparse import os # Suppress TensorFlow warnings since we're using ...
55d7f57ab030ed750b77aee213216d531c0c09b1ce0ac4ed05a2944d65a34028
Python
20,641
614
# -*- coding: utf-8 -*- """Flattening utilities.""" import datetime import math import os import shutil as sh import matplotlib.pyplot as plt import nibabel as nb import numpy as np import shapely.geometry as geometry from descartes import PolygonPatch from nibabel.freesurfer.io import read_geometry, write_morph_data...
6bf4faa583fe9d47af3e1e465d461526385a15b0686882d694204137f4f02fc0
Python
20,643
534
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ BundleSeg output visualization tool. This script allows visualization of segmented bundles and after-the-fact filtering to explore optimal thresholds for each bundle. It uses FURY for 3D rendering. It includes tools to slice images, filter streamlines, and interactive...
93d6f8e626a8be49324625931d38e794c2d7c1c8c534ede3fdf9b11059d5a1ed
Python
20,644
496
""" Vision Transformer (ViT) in PyTorch A PyTorch implement of Vision Transformers as described in 'An Image Is Worth 16 x 16 Words: Transformers for Image Recognition at Scale' - https://arxiv.org/abs/2010.11929 The official jax code is released and available at https://github.com/google-research/vision_transformer ...
237144e964d7425c562aa3ec1e00af5d365ee82b51c40d8f57a79557101d6b63
Python
20,645
513
import os import glob import tqdm import skimage.io as skio from natsort import natsorted import numpy as np from skimage import draw import json import skimage.exposure as skex import time import skimage as ski from pathlib import Path from multiprocessing import Pool, cpu_count class hipctPreprocessor(object): ...
14779b9c7f9ac369021ffb49ed32887916cb35b0330803ccec635b33687a85ea
Python
20,652
547
"""Publication-style TBSS/JHU axial mosaic without MRIcroGL. Layers, from back to front: 1. user supplied anatomical/FA background (grayscale) 2. JHU ROI statistic values (continuous colormap) 3. user supplied TBSS skeleton (green) The statistical CSV uses the same convention as the other cvdproc surface ...
d1380943a4532abc27df42879bb0d04924e4cf31bc07cf6ca4cc33671e7ca395
Python
20,652
613
import numpy as np import nelpy as nel from nelpy.core._eventarray import _restrict_event_series_to_intervals from nelpy.utils import ragged_array def _reference_restrict_events(events, intervals): events = np.asarray(events) pieces = [] for start, stop in intervals: start_idx = np.searchsorted(e...
1e0a873f5ce9dabde1058dbb946afba01ce08472b965339ea8171d97a6a02eba
Python
20,654
472
# /------------------------------------------------------------------------------+ # | 19-APR-2023 | # | Copyright (c) Bone Imaging Laboratory | # | All rights reserved ...
27404334a6c26a5cf2cfe38543c12e2902f62ad46207abb6d83a55dfe1050db9
Python
20,662
362
import argparse import multiprocessing import shutil from multiprocessing import Pool from typing import Union, Tuple, List, Callable import numpy as np from acvl_utils.morphology.morphology_helper import remove_all_but_largest_component from batchgenerators.utilities.file_and_folder_operations import load_json, subfi...
2fc7d8cb092f5a3b1bec015c72e8429f41956448eb49a352bb7ec73c6dc055a8
Python
20,664
554
# -*- coding: utf-8 -*- """ Fiducial Metrics Extraction Pipeline A modular, open-access tool for extracting anatomical measurements from 3D Slicer fiducial files. Features: - Extract distances and measurements from fiducial landmarks - Support for T1 and T2 modalities - Cross-platform path handling - Configur...
de9413f837f18c8b66f08eb509eb1fc62cb11a66cbd26ccaf21c60ee3a9c6ab2
Python
20,668
636
import numpy as np import numpy.random as npr import matplotlib.pyplot as plt from tqdm import tqdm import pickle as pkl import os from FORCE.utils import * class RNN: """ RNN via FORCE learning. API: .reset(reset_activity=True, reset_weights=True) .save_weights() .load_weights() .activation(x, beta...
dab5be2452c4fcf32332e3605931e0674692980a4de239a0e983ef5ac681b210
Python
20,669
403
# Copyright (c) 2026 Rohit Jena. All rights reserved. # # This file is part of FireANTs, distributed under the terms of # the FireANTs License version 1.0. A copy of the license can be found # in the LICENSE file at the root of this repository. # # IMPORTANT: This code is part of FireANTs and its use, reproduction, or...
12ad31c5f8bd042070db7c479e1911ae1c15d625889034b5ce6ba81635fc1b75
Python
20,686
686
import os import shutil import pytest from torch.optim import SGD from torch.optim.optimizer import Optimizer from torch.optim.adam import Adam import flair.datasets from flair.data import Dictionary, Sentence, MultiCorpus from flair.embeddings import ( WordEmbeddings, TokenEmbeddings, FlairEmbeddings, ...
df1b650b6872e1d1a75ff54fc182577111c4f49f2db63630048fa4dd33e115c2
Python
20,688
482
""" Module for evaluating the performance of task batteries for both simulations and real data. Author: Bassel Arafat """ import torch as pt import OptimalBattery.estimate as et import OptimalBattery.util as ut import numpy as np import OptimalBattery.construct as ct import Functional_Fusion.atlas_map as am import cort...
73682fc0726a7be990428198405e949ab19a1d1dd01172fcb9f4d943f078942b
Python
20,689
443
import os import torch import numpy as np import scipy.signal as sig import pandas as pd from scipy.sparse import csr_matrix from sklearn.model_selection import StratifiedShuffleSplit class TrialDataset: def __init__( self, root: str, sessions, areas, neurons, trial...
83bec99efc042c396896d898991411d547f5f565ee30ebc9d7c386208f8253a5
Python
20,689
594
# Source: https://github.com/neuraloperator/neuraloperator/blob/main/neuralop/training/trainer.py import torch from torch import nn from timeit import default_timer from pathlib import Path from typing import Union import sys import json from .losses import LpLoss from deepcardio.train_state import load_training_state...
21b3efa2132aa48c0635f13552cfea2eef9b15a1895b636a2ec16299143daa27
Python
20,699
311
import os import shutil from nipype.interfaces.base import CommandLineInputSpec, File, TraitedSpec, CommandLine, BaseInterfaceInputSpec, BaseInterface from traits.api import Str, Int, Directory, Bool, Either # usage: segment_subregions [-h] [--cross CROSS] [--long-base LONG_BASE] [--sd SD] [--suffix SUFFIX] # ...
e3c054773511237b981c932e66c9c10ca235810ed405e070a4eb0475363a065a
Python
20,706
360
"""A module that contains the base classes for pipelines, :py:class:`~corelay.pipeline.base.Pipeline`, and tasks of pipelines, :py:class:`~corelay.pipeline.base.Task`, which are used to perform a specific set of operations on data. """ import collections import typing from collections.abc import Callable from corelay...
8a3da6cb97267caf6b01c72afae546a60fd91990b2486e99dc2f535c926a5d8c
Python
20,731
538
import numpy as np import random import pandas as pd import sys class NoOtherItemsError(Exception): """Error that shows that list has only 1 item and randomly choosing will not produce something else """ pass def generate_stimulus_sequence(num_blocks, numerosity, stimulus_types): """Generates a sequ...
0dceb75b63058e4110b2c1997fc756571a3551098a7b9778b88c1cb524aad78b
Python
20,732
448
""" Spatial Gene Discovery Module for HarveST Discovers domain-specific spatial variable genes using random walk with restart (RWR) """ import numpy as np import pandas as pd import scanpy as sc import os import random import scipy.sparse as sp from tqdm import tqdm from pathlib import Path import warnings from typing...
0ae60beb12ebaeafbadf7fa3c50e038d218567902ccdcd19adad610dee24e775
Python
20,756
569
#Lucas Sancéré import os script_dir = os.path.dirname(os.path.abspath(__file__)) import lightgbm import numpy as np import xgboost import yaml from attrdictionary import AttrDict as attributedict from sklearn.metrics import balanced_accuracy_score from sklearn.model_selection import StratifiedKFold from histo_mine...
0f47cd619b40e7b5e65dc4fed1536887d4a2d8c6738d4c1e889938244e951f5e
Python
20,762
462
# This file contains a bunch of functions from Benjamin's lab2im package # (it's just much lighter to import...) import os,sys import nibabel as nib import numpy as np import argparse from scipy.interpolate import RegularGridInterpolator as rgi from scipy.ndimage import gaussian_filter as gauss_filt from scipy.ndimag...
4d091cf6ce000a4df78d5b0c5a4f497d9d07986cf255019a4f9c1522b890d3c1
Python
20,765
655
"""octagonal maze linearization""" import copy import numpy as np from ..core import _analogsignalarray, _epocharray from ..auxiliary import _position from .. import utils from ..plotting.core import colorline # TODO: linsmooth(), wrap(), unwrap(), assign_segments(), lin_to_ideal(), ideal_to_lin(), 2d_to_ideal() d...
6c4377478cbe48fcdf2ca8673d54283fd4fbd02b65a6262248348075a8dd09dc
Python
20,769
445
#!/usr/bin/env python # coding: utf-8 import os import random import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from torch.utils.data import DataLoader, Dataset from torch_geometric.nn import GCNConv from tqdm import tqdm from sklearn.model_selection import StratifiedKFold from skl...
ed01fb855e7ccb2b283db05e2ac7aa877d8ecc15de59880dc2f1d19a4d74d808
Python
20,770
446
#!/usr/bin/env python # coding: utf-8 import os import random import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from torch.utils.data import DataLoader, Dataset from torch_geometric.nn import GCNConv from tqdm import tqdm from sklearn.model_selection import StratifiedKFold from skl...
deeb82096da921ca910adbf75512b58b743436db260e43a8708635344754419c
Python
20,771
400
import numpy as np import pandas as pd import numba as nb from numba import jit import collections import random from .data_downsample import downsample_cell,downsample_matrix_by_cell from .data_augmentation import random_augment,random_augmentation_cell import logging # logging.basicConfig(level=print, # ...
e1f06e829f5c8211b603d5745407426ecad4005bfc525f276e69c02a779f3217
Python
20,777
504
import keras import keras.backend as K import keras.layers as KL import numpy as np from keras.models import Model import nibabel as nib def unet(nb_features, input_shape, nb_levels, conv_size, nb_labels, name='unet', prefix=None, feat_mult=1, poo...
e36bd5e02a575f70b49336e4102f13923a98213c332e45dbf9ddeccf49d94ed6
Python
20,787
440
import numpy as np import os import tempfile from ivim.models import NO_REGIME, DIFFUSIVE_REGIME, BALLISTIC_REGIME, INTERMEDIATE_REGIME from ivim.sim import noise from ivim.seq.lte import calc_c, G_from_b, MONOPOLAR, BIPOLAR from ivim.io.base import write_im, read_im, write_bval, write_cval, write_time, write_k from iv...
053156468fa07e97787bdaf95540b00c10e7ee87c09b1b16bd60d50bacec9946
Python
20,823
464
import numpy as np import pandas as pd import json import os import networkx as nx import pickle as pkl from collections import Counter import matplotlib.pyplot as plt import random import jieba from snownlp import SnowNLP from wordcloud import WordCloud import matplotlib.font_manager as fm path1 = r'E:\毕业论文\数据集\台湾选举...
4b2fb65dc8124073778c92a3eacc8f286a646d3a8225a43e5357228ba124fa5a
Python
20,826
456
import numpy as np import matplotlib.pyplot as plt from scipy.stats import sem from matplotlib.colors import ListedColormap, BoundaryNorm import matplotlib matplotlib.use('TkAgg') def plot_3d_line(ax, arr, set_color='lightblue', set_alpha=0.5, set_linewidth=0.5, set_label='None'): for i in range(arr.shape[0]): ...
b568bbc82daa791d221488a676cffecc237531571e58bd159a2fd793edb1fe2e
Python
20,838
551
""" Module to define updates for non-conjugate matrix factorisation models. Reference: 'Fast Variational Bayesian Inference for Non-Conjugate Matrix Factorisation models' by Seeger and Bouchard (2012) PseudoY: general class for pseudodata PseudoY_seeger: general class for pseudodata using seeger aproach Poi...
ef7d89fcc007440f233e356fb9900e43460089ec2aeadb6783be1fa32998b9da
Python
20,847
563
from typing import Optional, Union, Tuple from anndata import AnnData import numpy as np import pandas as pd from matplotlib.axes import Axes from matplotlib import colormaps from matplotlib.collections import LineCollection, PolyCollection from matplotlib.colors import Normalize from matplotlib.patches import Patch fr...
48ae6d1af6723ae509df85c8aeccd5a498beda47827cade4658509a0262c4274
Python
20,848
575
""" (C) Copyright 2021 IBM Corp. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
03c60e7ec929d39ad4e8d474a9045911a81430bf48eeae40c41393350127849f
Python
20,852
519
import argparse import os import shutil import sys import time import warnings from random import sample import numpy as np import torch import torch.nn as nn import torch.optim as optim from sklearn import metrics from torch.autograd import Variable from torch.optim.lr_scheduler import MultiStepLR from cgcnn.data im...
fb432cf8f20c00777e3d1ab780e8a80eb3494b0e856e93b2deb65a116d50f4c2
Python
20,863
489
import tensorflow as tf tf.compat.v1.disable_eager_execution() import numpy as np import logging import warnings warnings.filterwarnings('ignore', category=UserWarning) class ModelConfig: batch_size = 20 depths = 5 filters_root = 8 kernel_size = [7, 1] pool_size = [4, 1] dilation_rate = [1, 1] class_wei...
3362cf0fb8b4c5851ab0455e20dab0b42f3c66b02ba01c94fa4a03bc624ff7c3
Python
20,867
528
#pylint: skip-file #type: ignore """ Implementation of the simple task """ import time import math import enum import typing import asyncio import logging import datetime import numpy as np import os import stl from ..qt import * from . import task_context from .widgets import Form, ListAsTabsWidget from .util impor...
986986d7feb0105d55ddba49d66ddbe8907c17aa6f7cbee0257961a831fe77ed
Python
20,888
455
import numpy as np import matplotlib.pyplot as plt from scipy.stats import sem from matplotlib.colors import ListedColormap, BoundaryNorm import matplotlib matplotlib.use('TkAgg') def plot_3d_line(ax, arr, set_color='lightblue', set_alpha=0.5, set_linewidth=0.5, set_label='None'): for i in range(arr.shape[0]): ...
2c16afec5b16778e4eec1c798f855fa423bbd4873d8d5d32a2a998c9f7a1708c
Python
20,890
631
"""Train an ABMIL model for single- or multi-task regression. The inputs to the model are bags of embedded histology patches. The outputs of the model are scalar values representing the continuous predictions. """ from __future__ import annotations import dataclasses import json import math import random import shu...
964d34b0c4efba45d58d516cee1c077fad4dd9c45c038ed56abdf37d9effdbdb
Python
20,896
510
import sys import os import pandas as pd import pyreadr import torch import glob import functools import random import yaml import torch_geometric.transforms as T import torch.nn.functional as F from math import ceil from torch_geometric.data import InMemoryDataset, Data from torch_geometric.loader import DenseDataLoad...
79c2271f2901f42cd4aafbc17a5f23bb17fa0b641950e7ce2b509fbac8a969d7
Python
20,905
451
import sys import torch import torch.nn as nn import torch.optim as optim import numpy as np from datetime import datetime import torchvision.models as models import scipy.io as io import os from pathlib import Path import argparse import scipy.stats as stats import random import json from tqdm import tqdm os.environ[...
2bb186bb0c384e3c6ecbb2ab2083ab8029fe1fe13b296456411dfcf934b56560
Python
20,907
593
import abc try: import anndata except ImportError: anndata = None import batchglm.api as glm import dask import logging import numpy as np import pandas as pd import scipy import scipy.sparse import sparse from typing import Union from .det import _DifferentialExpressionTestSingle, DifferentialExpressionTestWa...
f4465315f06f77b80b9b5dce27e8f9729f1208131cf193bd819da40a08e42626
Python
20,914
449
#!/usr/bin/env python # coding: utf-8 import os import random import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from torch.utils.data import DataLoader, Dataset from torch_geometric.nn import GCNConv from tqdm import tqdm from sklearn.model_selection import StratifiedKFold from skl...