sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
45028f6d12e4752fca71735834e08217fc657ffafbe5b617004832a5b478975f | Python | 8,726 | 227 | import torch
from torch.nn import Module, BatchNorm1d, LeakyReLU, Conv1d, ModuleList, Softmax, Sigmoid, Flatten, Dropout2d, Linear
from torch.optim.lr_scheduler import LambdaLR
from torch.optim import Optimizer
from torch.utils.data import Dataset, DataLoader
import math
import random
import numpy as np
import warning... |
45a818397c014bf8b7c433baccd62832a39293d6bec55260bb39e57446137a70 | Python | 8,727 | 204 | proj_dir = "/path/to/main_project_folder/" # edit this line
import numpy as np
import random
import xarray as xr
import time
import h5py
import pandas as pd
from denseweight import DenseWeight
from sklearn.model_selection import train_test_split
from tensorflow.random import set_seed as tf_set_seed
from tensorflow.ker... |
f5b23d8baf808d578815f987e887822eae55682894bf329dfa5c2cb6b2a48e4c | Python | 8,733 | 225 | # Ultralytics YOLO 🚀, GPL-3.0 license
import glob
import math
import os
from multiprocessing.pool import ThreadPool
from pathlib import Path
from typing import Optional
import cv2
import numpy as np
from torch.utils.data import Dataset
from tqdm import tqdm
from ..utils import NUM_THREADS, TQDM_BAR_FORMAT
from .uti... |
b92053f92aef015d0dd63093b32e4ceadccb84697137325243f927ed6b09031a | Python | 8,735 | 185 | # coding=utf-8
# Copyright 2023 The HuggingFace Inc. team.
#
# 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... |
89612ca0ae30a76f3c978858e2418c489890ce3e98199b82f2fab574af933734 | Python | 8,736 | 209 | # Copyright 2021 Division of Medical Image Computing, German Cancer Research Center (DKFZ)
# and Applied Computer Vision Lab, Helmholtz Imaging Platform
#
# 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 L... |
a7e41320380b4eceb774b4786b77e978b8816e42d286337e36595ca5f00c6113 | Python | 8,736 | 215 | ####################################################################################################
# Copyright (c) 2023, EPFL / Blue Brain Project
# Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch>
#
# This file is part of NeuroMorphoVis <https://github.com/BlueBrain/NeuroMorphoVis>
#
# This program is free softw... |
9ddb245e77bb26fab28704a5747318a200c29fbf2a26069ae86a053b1db6be45 | Python | 8,737 | 176 | from pathlib import Path
import argparse
import json
import os
import random
import signal
import pickle
import sys
import warnings
warnings.filterwarnings('ignore') # "error", "ignore", "always", "default", "module" or "once"
import time
import urllib
import numpy as np
from datetime import datetime
from torch import... |
2e6544def90bd8d8f4653040f8ce3beb52aed4c8eb35e6fffe3f8adec9b9693f | Python | 8,738 | 262 | # -*- coding: utf-8 -*-
#
# neo documentation build configuration file, created by
# sphinx-quickstart on Fri Feb 25 14:18:12 2011.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All con... |
0b4ae37f306ea9497b162ab8f0e70a84b75f311b923459d84f52b3ecd802f80a | Python | 8,739 | 242 |
# ------------------------------------------------------------------------------------------------------------
# MS lesion segmentation pipeline
# ---------------------------------
# - incorporates:
# - MRI identification
# - registration
# - skull stripping
# - MS lesion segmentati... |
01f19e23459cf6f04426ee461b0d93632b183b096117547a96a91bc4c3d59381 | Python | 8,740 | 210 | # -------------------------------------------------------------------------------------------------------------------------------------
# Following code curated for Bio-Diffusion (https://github.com/BioinfoMachineLearning/bio-diffusion):
# --------------------------------------------------------------------------------... |
9770d55120221176ad79065f2fd67a3155255ecabfbb26c4174f2e5c92b23f7d | Python | 8,743 | 232 | # coding=utf-8
# Copyright 2022 HuggingFace Inc.
#
# 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 ag... |
f58aebf2bdce56430b1ebd02d6cd526e8737ad45ed065f27945d9edb328756e2 | Python | 8,744 | 231 | """
This module contains tests that run mozaik tools functions
"""
import numpy as np
import os
from mozaik.storage.queries import *
from mozaik.tools.datastore_utils import *
from mozaik.storage.datastore import PickledDataStore
from mozaik.storage import queries
from parameters import ParameterSet
import pytest
c... |
f48234a22b1d40aba2085f98c459637ccf9d2e5f8575352e1a920a5b86c01dda | Python | 8,746 | 238 | import json
import os
from collections import defaultdict
from dataclasses import asdict, dataclass
from typing import Dict, List, Optional, Union
import ray
class _NullLogSpan:
"""A log span context manager that does nothing"""
def __enter__(self):
pass
def __exit__(self, type, value, tb):
... |
a867b4aac683e2dbdc5a86c982848b15e489b79d9172d5f872464b1122e105f9 | Python | 8,747 | 222 | import os
import numpy as np
import pandas as pd
import pickle
from matplotlib import pyplot as plt
import seaborn as sns
import statsmodels.api as sm
import pingouin as pg
from pcntoolkit.normative import estimate, predict, evaluate
from pcntoolkit.util.utils import compute_MSLL, create_design_matrix, calibration_des... |
e0d497ace004017cabc0287d34d897542b064af63848a1e5c94ea85cefeac6b7 | Python | 8,748 | 226 | # coding=utf-8
# Copyright 2023 HuggingFace Inc.
#
# 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 ag... |
374297a4f106472954ba23c2e2c3798b29d7ef26994b99c3603ea61278a63926 | Python | 8,750 | 232 | import time
from sklearn.datasets import make_blobs
from sklearn.model_selection import train_test_split
from sklearn.cluster import KMeans, AgglomerativeClustering, SpectralClustering
from sklearn.svm import SVC
from sklearn.neighbors import KNeighborsClassifier
from reval.best_nclust_cv import FindBestClustCV
from sk... |
bdba808eab351e8164438854cc53ecc47267d94a50d9d37678aa037a0c90ff25 | Python | 8,751 | 250 | #!/usr/bin/env python
from __future__ import print_function
# %%
from builtins import str
from builtins import range
import caiman.source_extraction.cnmf.params
try:
if __IPYTHON__:
# this is used for debugging purposes only. allows to reload classes when changed
get_ipython().magic('load_ext aut... |
522c2a73ba19b0404bf994c720a760ef8a6d886b95f85413a4a25804acdf39aa | Python | 8,752 | 282 | from typing import Dict, List
import tensorflow as tf
from ml4h.models.Block import Block
from ml4h.TensorMap import TensorMap
Tensor = tf.Tensor
class PerceiverEncoder(Block):
def __init__(
self, *, tensor_map: TensorMap, dense_layers: List[int],
dense_regularize_rate: float, attention_heads... |
2d452559b5768d724f59bcb94a81c5974fdce6d31569096cc3e53fb3e5a379c6 | Python | 8,761 | 252 | from functools import partial
from typing import Optional, Tuple, Union
import nir
import nirtorch
import numpy as np
import torch
from torch import nn
import sinabs.layers as sl
def _as_pair(x) -> Tuple[int, int]:
try:
if len(x) == 1:
return (x[0], x[0])
elif len(x) >= 2:
... |
bf672ad7c130972b96c544b26d0a435c82ee462d6b5f4bf7864d7af09bcbe706 | Python | 8,761 | 231 | import torch
from torch.nn.parallel import DistributedDataParallel
import numpy as np
from tqdm import tqdm
from pathlib import Path
import time
import torch.distributed as dist
from torch.utils.tensorboard import SummaryWriter
class TrainerFineTuneRegression:
def __init__(self, model, path='./', parallel=Fal... |
68ed63286eb02fc220f639301b9653471e6b86a4f5a72a915895fb2ddce8d34d | Python | 8,762 | 215 | # Please see LICENSE.md for the full license document:
# https://github.com/AdaptiveMotorControlLab/CEBRA/blob/main/LICENSE.md
#
# 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.a... |
65c6d8f09ed24a4e7732273c31f16b4e18177690e24ab073fd1bddc1028f2c79 | Python | 8,763 | 177 | import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
from sklearn.cluster import KMeans, MiniBatchKMeans
import os
def kmeans_plot_multiple(embed_dict_t,graph_list,coords,taskname_t,output_path_t,k=20,dot_size = 10,scale_bar_t = None,minibatch = True,plot_strategy = 'sep',axis_off = False):
num... |
75a41641c04e229aed1f438026af4d01e97c4693b4951ddea751d57ae625ec37 | Python | 8,764 | 250 | """Export available simulation chunks and merge completed Experanto shards."""
from dataclasses import asdict, dataclass
import glob
import hashlib
import json
import math
import os
from pathlib import Path
import tempfile
from mozaik.tools.experanto_merge import CHUNK_EXPORT_META
DEFAULT_MODEL_NAME = "SelfSustained... |
1d0df6206ef6f98f9834ba3245ca754bde5e0ec62c4ce28f10c047b3e0eeae63 | Python | 8,765 | 272 | # Copyright 2023 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, sof... |
7309d5ea8c556eb87994b7ce3e6bcea4d6ffafa1f949f8d0b83fb86a3fefb23c | Python | 8,771 | 243 | # -*- coding: utf-8 -*-
# (C) Copyright 2020, 2021, 2022, 2023, 2024 IBM. All Rights Reserved.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#... |
ab3289c48c20d0dcce633eb1d5bd4278661622002e2695e86704dc53ad43e79e | Python | 8,772 | 217 | r"""I/O helpers for metabolomics data files.
Loads peak tables into AnnData with ``obs = samples``, ``var = metabolites``.
The assumption is that upstream peak picking / alignment (XCMS, MZmine,
MS-DIAL, OpenMS, Compound Discoverer) has already been done — this module
only handles the peak-table stage.
Supported form... |
c92f45dd517116b29bc04f3210b22f1e654fb4a3f81715d91b8d97ccca8ab04f | Python | 8,774 | 282 | # -*- coding: utf-8 -*-
# (C) Copyright 2020, 2021, 2022, 2023, 2024 IBM. All Rights Reserved.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#... |
07805f6683b6678bd3e10a960fae1ca1129f88d2d04fe060f915005cd3704b3c | Python | 8,775 | 258 | """
Copyright (c) Meta Platforms, Inc. and affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
from __future__ import annotations
import logging
import os
from typing import TYPE_CHECKING
import hydra
import numpy as np
import torch... |
24e3aa786ebc2619c244f5bafcdca5348af3301a0a5718e39de541a433de03d3 | Python | 8,775 | 264 | import os
import json
import hashlib
import struct
import uuid
from typing import Any, Dict, Optional, List, Union
from deepface.modules.database.types import Database
from deepface.modules.modeling import build_model
class QdrantClient(Database):
def __init__(
self,
connection_details: Optional[... |
fc037a9adec8d41577dbb63005b5611f61aefb2c85b0b446ae81ed14ae9abb0d | Python | 8,780 | 232 | import argparse
import os
import datetime
import scipy.stats as sts
import numpy as np
import pickle
import functools as ft
import general.utility as u
import general.stan_utility as su
def create_parser():
parser = argparse.ArgumentParser(description="fit several autoencoders")
parser.add_argument(
... |
66def073cda51d7ce8e7e0d30f88ecd201f2d32d5d4499bb4c80a27dc63cb787 | Python | 8,782 | 269 | """
Data structures for the OmicVerse Skills Verifier.
"""
from dataclasses import dataclass, field
from typing import List, Optional, Dict, Any
@dataclass
class SkillDescription:
"""
Minimal skill information using progressive disclosure approach.
Only name and description are loaded at startup (like C... |
749d3a1a9b25bc30ec7eecf3fe0cfdf4e4c90e89ef2ee822c38af45e00809ac0 | Python | 8,782 | 321 | """
Implementing "two networks with merging outputs" in https://github.com/synsense/sinabs/issues/181
"""
import torch.nn as nn
from sinabs.activation.surrogate_gradient_fn import PeriodicExponential
from sinabs.layers import IAFSqueeze, SumPool2d
dcnnl_map_3 = {
0: {
"input_shape": (2, 34, 34),
... |
7d15b23d4021b2897eb9c3694810451d6eecc7abeaad8de31307230cd102a3b2 | Python | 8,784 | 243 | import ast
from pathlib import Path
from types import SimpleNamespace
import numpy as np
import pytest
from parameters import ParameterSet
import mozaik
def sample_seed_streams():
return {
"model_rng": mozaik.model_rng.rand(5),
"model_pynn_rng": mozaik.model_pynn_rng.next(
5,
... |
8311e2d18620f09d0e0bf43af49833781df2720a5a212efd41c417e88d8ff790 | Python | 8,786 | 298 | #!/usr/bin/env python3
import argparse
from collections import namedtuple
from pathlib import Path
from typing import Iterable, List, Mapping, Optional, Sequence, Tuple
from warnings import warn
import numpy as np
import scipy.stats as st
from matplotlib import pyplot as plt
from sklearn.metrics import roc_auc_score,... |
6b5fc91671bab6318f222b9154e6b09e187ea0dc42991fe3a7d635653bb32599 | Python | 8,788 | 311 | conda activate scenic_protocol
cd /media/hansruedi/12TB_HD/SCENIC
python
import scanpy as sc
import numpy as np
import pandas as pd
adata=sc.read_csv("Ast_counts_matrix.csv")
row_attrs = {
"Gene": np.array(adata.var_names),
}
col_attrs = {
"CellID": np.array(adata.obs_names),
"nGene": np.array(np.sum(adata.X.trans... |
03688ca2e468ffb279d89826be4cee3210fef2f69c819504a3856552425fa569 | Python | 8,791 | 187 | """Plots for :func:`omicverse.single.compare_ccc` (agreement between communication methods)."""
from __future__ import annotations
from collections.abc import Mapping
from itertools import combinations
from typing import Literal
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from .._registry ... |
29fd3f1c81588af643fc990cae7e3adc62031e12ea31f5ba986dabcdc15ab792 | Python | 8,792 | 196 | ####################################################################################################
# Copyright (c) 2016 - 2024, EPFL / Blue Brain Project
# Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch>
#
# This file is part of NeuroMorphoVis <https://github.com/BlueBrain/NeuroMorphoVis>
#
# This program is fre... |
751215f2141b30649af23b62f49bf9de9dfeb020643cb0c7a9deb124ad1bd75f | Python | 8,793 | 250 | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils
import torch.distributions
from .pos_encoding import positional_encoding
import matplotlib.pyplot as plt
def rotate_by_theta(coords, theta, rotate_about=np.array([0,0])):
"""
Rotate coordinate array by ... |
2d90b593af0642173203ad9eedf43ae20f538b617f4e06bf0e5f63a7e9ba5224 | Python | 8,798 | 223 | from tqdm import trange
from sklearn import linear_model,preprocessing
import numpy as np
from scipy.stats import chi2
from sklearn.preprocessing import normalize
######################
# INPUTS:
# counts_mat: N x G matrix of counts
# gaston_labels, gaston_isodepth: N x 1 array with labels/isodepth for each spot (la... |
fe51aa1df958d139eafd165cc737478eb4c45354dd76f694fc17bdc985b93e4b | Python | 8,798 | 217 | # ML4H is released under the following BSD 3-Clause License:
#
# Copyright (c) 2020, Broad Institute, Inc. and The General Hospital Corporation.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#... |
2174c7917d7aeaf5a6f6bfb38e408dee332ea721a138904bb690c884030d3486 | Python | 8,804 | 221 | ####################################################################################################
# Copyright (c) 2016 - 2024, EPFL / Blue Brain Project
# Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch>
#
# This file is part of NeuroMorphoVis <https://github.com/BlueBrain/NeuroMorphoVis>
#
# This program is fre... |
4c10a33a03e995cae81e3b743d7250f9ecea7f4e9878173125fc94de300b8807 | Python | 8,805 | 209 | from fractions import Fraction
import numpy as np
import pytest
from stl import mesh
from .test_mesh_mass_mixed import subdivide
from .test_mesh_mass_sliver import _unit_cube, sliver
def box(center, size, sign=1):
data, _, _, _ = _unit_cube()
data['vectors'] = (data['vectors'] - 0.5) * size + center
if... |
10036523e17fea665627a942fa5e5f34cf82c0c796e49217113a69fd0316b8bc | Python | 8,812 | 266 | import argparse
import logging
import os
import socket
import sys
import ray
import ray._private.ray_constants as ray_constants
from ray._common.utils import (
get_or_create_event_loop,
)
from ray._private import logging_utils
from ray._private.authentication.http_token_authentication import (
get_token_auth_m... |
f7af97b13418f14fda627b5c678d48321021db55cd33a2e0c25bfbbe47850bb5 | Python | 8,812 | 242 | import copy
import numpy as np
import pandas as pd
from tqdm import tqdm
from .evaluate import compute_celltype_purity
from ..._anndata_compat import as_dtype as _as_dtype
def SEACells(
ad,
build_kernel_on: str,
n_SEACells: int,
use_gpu: bool = False,
verbose: bool = True,
n_waypoint_eigs: ... |
c07561cb22e3d372706efa7cbe2834178c24d9693ced6400156caa3ccb236e39 | Python | 8,814 | 221 | # -*- coding: utf-8 -*-
# (C) Copyright 2026 IBM. All Rights Reserved.
#
# Licensed under the MIT license. See LICENSE file in the project root for details.
"""Analog-aware inference optimizer."""
from types import new_class
from typing import Any, Callable, Dict, Optional, Type
from torch import cat
from torch.opt... |
0ede967bb44e3588167f387803f55962882e4b652d15c400252a8943b71a0e5b | Python | 8,819 | 233 | ####################################################################################################
# Copyright (c) 2016 - 2024, EPFL / Blue Brain Project
# Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch>
#
# This file is part of NeuroMorphoVis <https://github.com/BlueBrain/NeuroMorphoVis>
#
# This program is fre... |
9fa389e3f677d4a6eea9f15472063171cd7048c629a815089d6eb4f19f889106 | Python | 8,820 | 261 | # -*- coding: utf-8 -*-
# (C) Copyright 2026 IBM. All Rights Reserved.
#
# Licensed under the MIT license. See LICENSE file in the project root for details.
"""Analog RNN modules."""
import warnings
import math
from typing import Any, List, Optional, Tuple, Type, Callable
from torch import Tensor, jit
from torch.nn... |
1890949c8e60e47d5d1e3dd3c75fbda139564f80b3aca2e8fe58c268b462b3ea | Python | 8,822 | 271 | """Dependency-safe tool scheduler for OVAgent turn execution.
Partitions an ordered sequence of tool calls into execution batches
based on ``ParallelClass`` policy metadata from the ``ToolRegistry``.
Read-only tool calls that appear consecutively may execute concurrently
within a single batch, while stateful, approval... |
2a825b7c22fb495b17f9b54ec64b0a13b1243460ba89a6c89d72f6d217272796 | Python | 8,823 | 255 | import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
def plot_tensor_single(adata, adata_aggr = None, state = 'joint',
attractor = None, basis = 'umap', color ='attractor',
color_map = None, size = 20, alpha = 0.5, ax = None,
s... |
e8d4ddcf4044b3fd37caccebdc904f1e5dd38aa37551c8caacfb4e714ac484b6 | Python | 8,823 | 232 | """
This file has the functions necessary to create the SpliceAI and related resnet models.
"""
import torch
import torch.nn as nn
from functools import partial
from .model_utils import cross_entropy
from loguru import logger
def residualunit(l, w, ar, dropout=None, norm="BN"):
w = int(w)
ar = int(ar)
if ... |
6d381bfd01db332400cb57fc63410d684efe52e34818fcd3b3e799cfe1d35c6a | Python | 8,824 | 168 | #!/usr/bin/env python
# finalise output
import numpy as np
import pandas as pd
import collections
import os
def generate_aggregated_classification(df, categories):
'''
Aim: Create one big table with a row for each transcript and a "1" if the event is present
Table is for downstream prioritising of ... |
e4ffe1ef40dad336868cc33daf156276897c77cda46aa8560a1ec564b9de01a9 | Python | 8,828 | 223 | # -*- coding: utf-8 -*-
"""
Created on Tue Sep 22 15:16:00 2020
@author: ju-bar
Functions related to optical focus spread
This code is part of the 'emilys' repository
https://github.com/ju-bar/emilys
published under the GNU General Publishing License, version 3
"""
from numba import jit # include compilation support... |
84077451b91e92a38d5017df8ac89c7ee6d527a9417f3f0ce4301036701abc9b | Python | 8,831 | 305 | """
Edge-of-chaos measures
"""
import numpy as np
import scipy.signal
import scipy.stats
def chaos_pipeline(data, sigma=0.5, denoise=False, downsample='minmax'):
"""Simplified pipeline for the modified 0-1 chaos test emulating the
implementation from Toker et al. (2022, PNAS). This test assumes
that the s... |
be6595bd506700097a98006d67c0e71bc5c3f090ae3eca524ba4fd00381100aa | Python | 8,833 | 255 | #!/bin/env python
import argparse
import pysam
import sys
from typing import Optional, List, Text, Set
_gt_map = dict()
_cnv_gt_map = dict()
def _cache_gt(gt):
if gt is None:
return 0, 0
s = _gt_map.get(gt, None)
if s is None:
x = sum([1 for a in gt if a is not None and a > 0])
i... |
c15fbbfc76bcbc8d7a608fbe22f96a6036c601d1a9fb23c67d3072758b0bd404 | Python | 8,834 | 135 | import os
import argparse
import easygrid
import pdb # DFR add 8-31-21
# Stages
MAKE_TEMPLATE_FILES = 'make_template_files'
TRAIN_MODELS = 'train_models'
SCORE_SUMSTATS = 'score_sumstats'
GATHER_SUMSTATS = 'gather_sumstats'
if __name__ == '__main__':
parser = argparse.ArgumentParser('Script to generate LD score r... |
e7b3c7167b69a47951980f94374277299b93e05af50b94d2ca20c2e660e8af28 | Python | 8,835 | 249 | from dataclasses import dataclass
from pathlib import Path
from typing import TYPE_CHECKING, Any
import numpy as np
import rioxarray
from numpy.typing import NDArray
from PIL import Image, ImageOps
from siapy.core.exceptions import InvalidFilepathError, InvalidInputError
from .interfaces import ImageBase
if TYPE_CH... |
58393198e0f961a582364356f3da8cc75c29f5530597783a2219c9405f0d39e8 | Python | 8,836 | 316 | #!/usr/local/bin/python
"""
***********************************************
- PROGRAM: getEigenVectors.py
- CONTACT: Bryan lajoie (bryan.lajoie@umassmed.edu)
***********************************************
"""
from __future__ import print_function
from __future__ import division
import numpy as np
import scipy as sp
... |
0211fd06c797cfc4d9bb66070dd56907f6f318de4d053733ecbd9d29890070f4 | Python | 8,839 | 235 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 27 14:46:44 2021
@author: irisstone
Various analysis functions for evaluating the results from fitting glm-hmms (as used in Bolkan, Stone et al 2022)
"""
import numpy as np
import scipy.io as sio
from glmhmm.utils import convert_ll_bits, reshape_... |
5100b06c9466dfe59b5aeb487300c0ba0df2e0a87b87b07e8c56cde1672f95d8 | Python | 8,842 | 252 | import os
from progress.bar import Bar
from pyfaidx import Fasta
import pandas as pd
SEQ_LENGTH = "800"
QUARTER_SEQ_LEN = int(SEQ_LENGTH) // 4
'''Obtain chromosome size'''
def get_chrom_size(path):
chrs = {}
with open(path, 'r') as file:
# read the file line by line
for line in file: ... |
0d85ffbe20ddc152d1a88aa7f9a221465d621c81f87722410e2870246fa0c82c | Python | 8,844 | 238 | import os
from spinnaker2.coordinates import PE
import spinnaker2.mapper
import spinnaker2.neuron_models
from spinnaker2.configuration import Experiment, ExperimentConfig
from spinnaker2.helpers import read_log, read_spikes, read_voltages
import time
def map_and_generate_experiment_config(network, hardware, time_steps... |
fd681974d73150a77fcf722b69ea8e4fa51ec782fa61890af987e04ee34895a4 | Python | 8,847 | 253 | import os
from progress.bar import Bar
from pyfaidx import Fasta
import pandas as pd
SEQ_LENGTH = "800"
QUARTER_SEQ_LEN = int(SEQ_LENGTH) // 4
'''Obtain chromosome size'''
def get_chrom_size(path):
chrs = {}
with open(path, 'r') as file:
# read the file line by line
for line in file: ... |
c838688ed0dbf0ec4ec6d23cce6afeffa9428d43cd5ac6276a975948859938d5 | Python | 8,848 | 221 | # Copyright (c) DP Technology.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn.functional as F
from unicore import metrics
from unicore.losses import UnicoreLoss, register_loss
@register_loss("unimol")
class UniM... |
bea2ad9c1280a4579329863b0d2c773e14ea262cd02b736ebe964e832e186a8f | Python | 8,851 | 219 | """Session/context facade mixin — extracted from OmicVerseAgent.
Owns lazy-service construction, session-ID delegation, tracing/runtime
bootstrap, and the public session/context API surface. The concrete
agent class inherits this mixin so that the methods appear on
``OmicVerseAgent`` without bloating its class body.
... |
bf141f63f619a18c93f1ab42ce3057ae53924d720b43349e41c5159fd719bf8b | Python | 8,856 | 240 | import numpy as np
from utils import to_pth
# constants
DIM_CONTEXT = 2 # the dimension fo the context vector
B = 2
CTX_VAL_2_LR = {0 : 'l', 1: 'r'}
class MixedCSW():
'''the T x B coffee shop world, where B = 2
graph:
here's the CSW with event_len = 3 (see andre/silvy's paper):
1 - 3 - 5 - 7
x... |
a0dd2b0a4692f5c2ff2684d7e249b7af6323069a7e6d81c2c38e707ddd752ff9 | Python | 8,860 | 209 | import re
from typing import List, Dict, Tuple
import json
# import torch
from datetime import datetime
from common import TrainingRecord, TrainingScenarios, SEED
from utils import load_json_file, append_date, dump_as_pickle, load_pickle
from tqdm import tqdm
from pathlib import Path
from keras.callbacks import Call... |
1f8cbf6da6e7c84163e93195c5e8132b59969b3c97c9c0e47104e0b786bc63d1 | Python | 8,861 | 194 | import argparse
import pickle
import numpy as np
import torch
import lib.data_utils.data_util as du
import lib.data_utils.dynamic_data_util as ddu
import lib.dataset_config_parser.dataset_config_parser as dcp
from denoise_inverse_alg.glm_inverse_alg import reinflate_cropped_glm_model
from eval_fns.eval import MaskedM... |
c54cc8d2138adfb57c93958555e196653cfc755ea7048a0b75d00b4fcc78ab10 | Python | 8,866 | 260 | import argparse
import os
import shutil
import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
import pdb
from PIL import Image
from scipy.io import loadmat
from torch.autograd import Variable
from torchvision import transforms
from torchvision.models.segmentation import segmentation as segme... |
618b8c5d383a03a78d9d07631c2f5ee4ba47f8585e58b8647b448990a3b93a12 | Python | 8,867 | 232 | import os
import csv
import pytest
import numpy as np
from collections import defaultdict
from ml4h.defines import TENSOR_EXT
from ml4h.tensor_generators import _sample_csv_to_set, get_train_valid_test_paths, get_train_valid_test_paths_split_by_csvs
def _write_samples(csv_path, sample_ids, use_header=False, write_du... |
ff2bb853bf807ba64fa9dd3e74bc5e93c31fe38de234fc1bcab7f12d01b78473 | Python | 8,867 | 229 | import h5py
import numpy as np
from tensorflow.keras.models import load_model
import deepinterpolation.loss_collection as lc
from tqdm.auto import tqdm
class fmri_inference:
# This inference is specific to fMRI which is raster scanning for
# denoising
def __init__(self, inference_param, generator_obj):
... |
1e7f3aded1ec1984b509deae38fbf3c50aba6b44f8a7d2ed25523687675b3622 | Python | 8,870 | 250 | # Copyright 2026 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... |
b6491359e442cad5bd8f8a543f0ddeac115a70a2a931224a4e0dac824043de9f | Python | 8,870 | 212 | import numpy as np
import torch
import torch_geometric.transforms as T
from torch_pgn.data.dmpnn_utils import MolGraphTransform
import os
import os.path as osp
import shutil
# Content: Index in the bond_feature which holds distance information
DISTANCE_INDEX = 0
class OneHotTransform(object):
"""
Transform o... |
0213b5b76ff905c16cf901ec08cedbdc8b03cf548f1e7a97db3df8b3051bf406 | Python | 8,872 | 308 | from typing import List, Dict, Optional, Any
import numpy as np
from neuron_morphology.morphology import Morphology
from neuron_morphology.transforms.transform_base import TransformBase
class AffineTransform(TransformBase):
"""Handles transformations to a pia/wm aligned coordinate frame."""
def __init__(se... |
c8c1b12d2b970a2a54e1919d4ed1f2cbaae9a60b159856651ccd5a96bd182463 | Python | 8,872 | 238 | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
def conv3x3(in_planes, out_planes, stride=1):
return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride, padding=1, bias=False)
class BasicBlock(nn.Module):
expansion = 1
def __init__(self... |
f95de05c5a968f68c798e39ee97d9a33da0eaaab87348056f24e4494ed2f42a0 | Python | 8,873 | 264 | """
The intention of this script is to easily sync a given Roche 454 run path from the sequencer into the :doc:`NGSData <../ngsdata>` structure
You need to ensure that the run directory for the run you want to sync is available and that you know the path to it.
You need to have the Data Analysis
Accessing Roche 454 ... |
d4bb206b1c0415b9095fdcc5175cf15cc3d8d78a4c71213a23693bb74f72c85c | Python | 8,874 | 166 | from torch.utils.data import DataLoader
import sys
sys.path.insert(1,'../src_VI/')
import torch
import numpy as np
import pandas as pd
from full_slab_spike_model_constructor import *
from training_func import *
from sklearn.preprocessing import StandardScaler, OneHotEncoder
class ZIV(object):
def __init__(self, d... |
10efa7db9155491bb9ad61f989e6cbf72c89838f59d9c5a899c802a6685b7032 | Python | 8,876 | 253 | # the core model for SMTRI
import numpy as np
from numpy import loadtxt
import pandas as pd
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import regularizers
from tensorflow.keras import Input
from tensorflow.keras import Model
from tensorflow.keras.layers import Dense
from tensorflow.kera... |
ac53527078142200eb509e8f8b7e9a56fdcb1ac48d192d30062b7d483007fb23 | Python | 8,876 | 301 | from scipy.spatial.distance import cdist
import numpy as np
import warnings
def mds(X, no_dims, use_gpu=True, verbose=False):
"""
This function performs MDS embedding.
Now supports GPU acceleration via MLX (Apple Silicon) or Torch (CUDA).
Parameters
----------
X : array-like
... |
09cebb9c648d5bf697c893f2d8f06bce7e17144594b057f22a1eb44f4d46c5d7 | Python | 8,879 | 235 | #
# CEBRA: Consistent EmBeddings of high-dimensional Recordings using Auxiliary variables
# © Mackenzie W. Mathis & Steffen Schneider (v0.4.0+)
# Source code:
# https://github.com/AdaptiveMotorControlLab/CEBRA
#
# Please see LICENSE.md for the full license document:
# https://github.com/AdaptiveMotorControlLab/CEBRA/bl... |
52735889c73e100256faf3158185562334bc5e9038b2ec737d1336c9b72d88af | Python | 8,879 | 283 | from __future__ import annotations
from dataclasses import dataclass
import numpy as np
from nir.ir import NIRGraph, NIRNode
@dataclass
class TimeGriddedData:
"""
Either boolean entries indicate whether a binary event is present at a
particular time step, or a real-valued signal provides the measuremen... |
b7bc35e5cb3aa62b60162de2f40903c68dc939ad5632076b24168c533daa276b | Python | 8,879 | 291 | from typing import Any, Callable, Sequence, Tuple, Union
import torch
from rising.random import AbstractParameter, DiscreteParameter
__all__ = ["AbstractTransform", "BaseTransform", "PerSampleTransform", "PerChannelTransform", "BaseTransformSeeded"]
augment_callable = Callable[[torch.Tensor], Any]
augment_axis_call... |
ddb0aeec2d7be61f8988bfc02a9ab3ad040e6f6e14cc577a3ec128d625c70064 | Python | 8,880 | 277 | """
Copyright (c) Meta Platforms, Inc. and affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
from __future__ import annotations
import os
import tempfile
import time
import hydra
import torch
from omegaconf import OmegaConf
from ... |
91bd7965d4392f9e29a64aff72b0807a84c2f5a37f941857b4cb7cb4199faada | Python | 8,881 | 217 | # coding=utf-8
# Copyright 2023 The HuggingFace Inc. team.
#
# 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... |
66259fdecd271c10273bd1e9c69266fbeb9cb1a62530bc0100d750fdcaf96954 | Python | 8,885 | 251 | import yaml
import sys
# import pickle
import logging
import click
import copy
import zarr
import numpy as np
from numcodecs import Blosc
from pathlib import Path
from deeprvat.utils import (
standardize_series,
my_quantile_transform,
)
logging.basicConfig(
format="[%(asctime)s] %(levelname)s:%(name)s: %(... |
22f33da8be48d5008cab025410c73dfe3caf53137a28044b7714bbfc456d5dad | Python | 8,886 | 172 | import mne
import json
import os
from pathlib import Path
import numpy as np
import pandas as pd
from general_utilities.path_helper_function import list_subjects, load_epochs
from general_utilities.simulate_malfunction import jitter_trials, shuffle_triggers
from general_utilities.data_helper_function import compute_epo... |
c6cbcb67842b610b786760a0598285e45eaea4012da620eba19c1b8b51e7bbd3 | Python | 8,889 | 269 | """
Copyright (c) Meta Platforms, Inc. and affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
Measure ASE molecular-dynamics step times for OMol models on 1000-atom diamond Si.
"""
from __future__ import annotations
import argparse
imp... |
e1b2419b8a34e25334bd3192f6906ebb5934e0872bf6f7bb8c7913da1361dc36 | Python | 8,889 | 253 | """
Copyright (c) Meta Platforms, Inc. and affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
CPU tests for the standalone UMA Nitro model: checkpoint loading, the MOLE merge
and weight layouts against HydraModel, settings checks, and th... |
0bab7cd45553e93731e602b49215fea55a3b425b8c9ab0a589e164d6482cbbd2 | Python | 8,895 | 249 | # built-in dependencies
import os
from typing import Any, Callable, Dict, List, Optional, Tuple, Union, cast
# 3rd party dependencies
import numpy as np
from numpy.typing import NDArray
# project dependencies
from deepface.commons import weight_utils
from deepface.commons.logger import Logger
logger = Logger()
# on... |
e54d0e89ffd9f103fddc1b38283e5322d61ed8225486a5d2d3cdfcc4b7b21743 | Python | 8,899 | 281 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# -------------------------------------------------------------------------
# Created By : Kangjoo Lee (kangjoo.lee@yale.edu)
# Last Updated: 08/06/2024
# -------------------------------------------------------------------------
# =========================================... |
dc41bfd4c0524010a783355c2a3f8f464b90f497ea4175be2c4d543aa1e29ae8 | Python | 8,900 | 240 | """
Manual overrides for manifest entries, schemas, and naming.
This module is the single place for:
- Resolving duplicate registrations (e.g. ``convert_to_pandas``)
- Forcing specific tool names
- Patching JSON Schemas for kwargs-heavy or weakly-typed functions
- Controlling rollout phase whitelists
"""
from __futur... |
238377a4a1a06541d641ee3c903213d9110867aee3032fc1edf6b963b59cd0e8 | Python | 8,902 | 192 | import torch as th
import torch.nn as nn
from tqdm.auto import tqdm
from .atac_dataloader import ATACDataset
from .utils import normalize, sparse_mx_to_torch_sparse_tensor, as_float_ndarray
import os
import numpy as np
import matplotlib.pyplot as plt
# Detect device - use CUDA if available, otherwise use CPU
device = ... |
16074cefe3802df10c8fbb25cc19a6c69a2ee3e959f47c01f8063f8702213b9a | Python | 8,907 | 213 | import numpy as np
import sys, os
from geopy import distance
import random
from PIL import Image
from PIL import ImageOps
from PIL import ImageDraw
from PIL import ImageFont
from numpy import asarray
from skimage.measure import block_reduce
import matplotlib as mpl
from matplotlib import pyplot as plt
from matplotlib i... |
e4abe3cc6f811c5b047d1fa6784275a7fdc32aba7717a63efceb5e924090e47b | Python | 8,908 | 236 | r"""QC-based batch / drift correction for LC-MS metabolomics.
ComBat (``ov.bulk.batch_correction``) handles batch *shifts* when the
batch variable is a known categorical — but the dominant confounder in
LC-MS untargeted runs is *within-batch signal drift* caused by
ionization-source fouling, column aging, and evaporat... |
27dac72e10e9f5aab4399b25d7e3069c64b6753c59ed01dc2e7004cfbdee5aa0 | Python | 8,912 | 195 | """
This script is used to threshold images with different methods and save the thresholded images.
The thresholded images are used to create the masks for the segmentation and naively analyse the data.
This makes it easier to preprocess whole folders with the same technique instead of having to use ImageJ.
(c) 2023, M... |
3f352f78be839e0f5004e469448d8db15988d682c25e10b2403040d49485a42d | Python | 8,915 | 199 | #!/usr/bin/env python
import sys
import os
from typing import Tuple, List, Text, Optional, Iterator, Collection, Set
import argparse
import numpy
import pysam
from sv_utils import common, genomics_io, pedigree_tools
class Default:
num_splits = 5
num_threads = common.num_physical_cpus
output_folder = os.g... |
7950af86531a7138c51294e4a25078cb67550e9b0bfc88ecac85ff7b0c67e593 | Python | 8,915 | 221 | """
Loop over datasets.
For each, load pupil.
Split pupil into trial types (HIT, CORRECT_REJECT, MISS, FALSE ALARM vs. PASSIVE)
Create supplemental figure that shows
1. baseline pupil reflects behavior (so impulsivity, basically)
1.2. baseline pupil shows inverted U (incorrect trials have either bigger or smal... |
7d6da7a70646351eaeec943bcfeff2f5dcc265d043e45c93388a55c6f5addf41 | Python | 8,915 | 215 | """
Explanation of Key Components
Embedding Layer: Maps each (phase,magnitude)(phase,magnitude) pair to a higher-dimensional space.
Positional Encoding: Provides positional information to the model.
Multi-Head Attention: Captures relationships across the sequence.
Feed-Forward Network: Enhances the cap... |
3dff90865db82f02b2bbeeec2570d1610ff70cdffb677310ca3de536c18a4da1 | Python | 8,917 | 270 | from copy import deepcopy
from functools import partial
from typing import List, Tuple
import numpy as np
import torch
from torch import nn
import sinabs.layers as sl
from .discretize import discretize_conv_spike_
# Define sum pooling functional as power-average pooling with power 1
sum_pool2d = partial(nn.function... |
5044aefad31d4216dd560f614a0205cabf62ae58db5762b20b323f2d48a5124b | Python | 8,920 | 314 | import argparse
import os
import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
from torch2trt import torch2trt
from PIL import Image
from torch.autograd import Variable
from torchvision import transforms
import cv2
import time
import argparse
from torch.nn import functional as F
import ... |
e08800a4313a043d2191f4cbeeacd2bd27fa2367a0be26e0b77c4071bb5935ae | Python | 8,922 | 314 | import argparse
import os
import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
from torch2trt import torch2trt
from PIL import Image
from torch.autograd import Variable
from torchvision import transforms
import cv2
import time
import argparse
from torch.nn import functional as F
import ... |
e8c6ae65ccd3dc203faf5d126e9bbe655dc816d1651fcf668fcec14eeea3544a | Python | 8,922 | 276 | import os.path as op
import os
from fsub_extractor.utils.system_utils import *
def trk_to_tck(trk_file, out_dir=os.getcwd(), overwrite=True):
"""Converts a .trk file to .tck using DIPY
Parameters
==========
trk_file: str
Path to .trk file
ref: str
Path to image (.nii.gz) in... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.