sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
540b78575d26fbf9652dff2203b60d69cf35cefbe4ae5b69a37afa6070d063f2 | Python | 889 | 29 | import torch
from torch import nn
from torch.nn.parameter import Parameter
class eca_layer(nn.Module):
"""Constructs a ECA module.
Args:
channel: Number of channels of the input feature map
k_size: Adaptive selection of kernel size
"""
def __init__(self, channel, k_size=3):
su... |
36a8a10557aa70a6a143230a8566810a9ac53f73d0f9cdce54125d4b5243a4d5 | Python | 890 | 35 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@author: GM
@edited: CD
"""
import numpy as np
from torch.utils.data import Dataset
import torch
class mri_dset(Dataset):
'''
Custom dataset class for mri images during training and validation.
'''
def __init__(self, df, partition=None,
... |
6c9dad4a1a0c3273da768cb6b68e62a7ea543079b2de5c189ef5501dad9c5df2 | Python | 890 | 26 | import subprocess
import sys
import yaml
script = 'flatmaps/plot_flat_zeta_responder_and_hierarchy.py'
scripts = [script]#[script_calc]
pathpath = 'PATHS/filepaths_carlen.yml'
with open(pathpath, 'r') as myfile: pathdict = yaml.safe_load(myfile)
sys.path.append(pathdict['code']['workspace'])
from pfcmap.python import... |
72b5a296c198ce2b342c4da014c40749adf5e00d4e269c56faf1be7f7bbbdf8c | Python | 890 | 26 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import tempfile
from scilpy import SCILPY_HOME
from scilpy.io.fetcher import fetch_data, get_testing_files_dict
# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['connectivity.zip'])
tmp_dir = tempfile... |
778bc9195572b0848d5ef7ad1f8060beb4670e593d568c22fd0656c13b1a9f0b | Python | 890 | 31 | #!/usr/bin/env python
# Remove reads with phred less than 20
# Have to make this as there doesn't seem to be anything around that allows me to do this!
# Write out as BAM file to save space
import sys
import pysam
import numpy as np
def remove_low_qual_reads(input_bam_filename, out_bam_filename, phred_threshold):
... |
8e09e0dfb2778c32c452f75c3637f53c0a860611d5281e8aa42a8f705e790b88 | Python | 891 | 29 | import numpy as np
def wavelet_freqs(fs, n_freqs):
nyquist_freq = fs / 2
freqs = np.arange(1, n_freqs + 1)
# Calculate the frequencies corresponding to each index
frequencies = nyquist_freq * (2 ** (-(n_freqs - freqs) / 24)) #maybe change the 24 for future applications
return frequencies
de... |
130c955f0cb968c2e4d162a74b2de5e69d5daef949eedd9c8c3422aba32c5c8f | Python | 892 | 23 | #############################################################################
# Copyright (C) 2020-2026 MEmilio
#
# Authors: Daniel Abele
#
# Contact: Martin J. Kuehn <Martin.Kuehn@DLR.de>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Licen... |
3473658fb25fabb5abd1c123046e26116d27999cbdd70b72e68133fabffdb57a | Python | 892 | 27 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import tempfile
from scilpy import SCILPY_HOME
from scilpy.io.fetcher import fetch_data, get_testing_files_dict
# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['atlas.zip'])
tmp_dir = tempfile.Tempor... |
73628d2599789991303cadc52a871619ebb49b5b4d9d241102cb34aeef34fe6a | Python | 893 | 38 | class Node(object):
""" A simple node class used for building a tree
"""
def __init__(self, identifier, data=None, parent=None):
self.__identifier = identifier
self.__children = []
self.__data = data # The node's data payload. Can be anything.
self.parent = parent
... |
92df3880f5fe04d0170ea45dfecea5a327b7f4c07f29de913eae2248c6758c66 | Python | 893 | 26 | from argparse import ArgumentParser
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
from django.utils.module_loading import import_string
class Command(BaseCommand):
help = "Run a configured periodic job immediately"
def add_arguments(self, parser: Argument... |
a7ab430645779be04fb91d3994c69bebf7a170a57782d6d58af0c8c9b246369d | Python | 893 | 33 | """
High level operations on genomic intervals. Most accept and produce iterables
of `bx.io.inervals.io.GenomicInterval` objects.
"""
BED_DEFAULT_COLS = 0, 1, 2, 5
MAX_END = 512 * 1024 * 1024
def bits_set_in_range(bits, range_start, range_end):
"""
Yield start,end tuples for each span of set bits in [range_s... |
d5809ec62ce52f58d0ef98befe6bfbcc7532e224f07eb02413d794144fb04a67 | Python | 893 | 23 | #############################################################################
# Copyright (C) 2020-2025 MEmilio
#
# Authors: Agatha Schmidt, Henrik Zunker
#
# Contact: Martin J. Kuehn <Martin.Kuehn@DLR.de>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in complian... |
2ca7414d26f82e765031236efb7b4b25d56c7bcb89040755d7abc480dd9580c4 | Python | 894 | 29 | import pytest
from pytest import approx
from brainscore_vision import benchmark_registry, load_benchmark, load_model
class TestExist:
@pytest.mark.private_access
@pytest.mark.parametrize("identifier", [
'Gifford2022.IT-ridge',
'Gifford2022.IT-ridgecv',
])
def test_benchmark_registry(s... |
490bf33c84bbcef70acaedf692877aa94807c4b2cab5e87afead35700aee9fdd | Python | 895 | 21 | from brainscore_vision import benchmark_registry
from .benchmark import (
Li2026V1RidgeCV, Li2026V2RidgeCV, Li2026V4RidgeCV, Li2026ITRidgeCV,
Li2026V1RDM, Li2026V2RDM, Li2026V4RDM, Li2026ITRDM,
Li2026V1PLS, Li2026V2PLS, Li2026V4PLS, Li2026ITPLS,
)
benchmark_registry['Li2026.V1-ridgecv'] = Li2026V1RidgeCV
b... |
74c5ece0fb840ea26ba1a3a6941b6d4e98cc95a7973220781f86daac32adcef7 | Python | 895 | 23 | import os
import pickle
def load_class_map(map_or_filename, root=''):
if isinstance(map_or_filename, dict):
assert dict, 'class_map dict must be non-empty'
return map_or_filename
class_map_path = map_or_filename
if not os.path.exists(class_map_path):
class_map_path = os.path.join(r... |
b44ede08c7c3e4225d3314ebfd3187b89037be07800472668996cc2c40fcaba8 | Python | 895 | 43 | import sys
sys.path.append('../')
import jieba
import jieba.analyse
from optparse import OptionParser
USAGE = "usage: python extract_tags_with_weight.py [file name] -k [top k] -w [with weight=1 or 0]"
parser = OptionParser(USAGE)
parser.add_option("-k", dest="topK")
parser.add_option("-w", dest="withWeight")
opt,... |
f659d9b79ba04c257cf3bd707c97e84826c99739655366774fc879216963656d | Python | 896 | 28 | from typing import List, Type
from brainways.utils.cell_detection_importer.brainways_cell_detection_importer import (
BrainwaysCellDetectionsImporter,
)
from brainways.utils.cell_detection_importer.cell_detection_importer import (
CellDetectionImporter,
)
from brainways.utils.cell_detection_importer.keren_cell... |
aaf8e25c157b19fa742221ebc79ba9bd5cccd24e587f2e21c0740d858ee06df5 | Python | 897 | 24 | """
Determine the number of bases covered by a set of intervals.
"""
from bx.intervals.io import BitsetSafeReaderWrapper
from bx.intervals.operations import MAX_END
def base_coverage(reader):
# Handle any ValueError, IndexError and OverflowError exceptions that may be thrown when
# the bitsets are being crea... |
598c7a852fa0c98ce9e0ef526b0dcd1ed69637e2fe307edfcdb3fe3662ecdb26 | Python | 898 | 55 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
import anndata
import numpy as np
import scvelo as scv
import pandas as pd
import sys
sys.path.append('../../../')
import velovae as vv
import time
import os
# In[2]:
root = '< your root path >'
dataset = 'BMMC'
adata = anndata.read_h5ad(f'{root}/data/{dataset}_pp.h... |
7c174484e45b76790c265cbe986a2de6ba7a2bd413e3f88ad7e201eb1218f7a7 | Python | 898 | 55 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
import anndata
import numpy as np
import scvelo as scv
import pandas as pd
import sys
sys.path.append('../../../')
import velovae as vv
import time
import os
# In[2]:
root = '< your root path >'
dataset = 'IPSC'
adata = anndata.read_h5ad(f'{root}/data/{dataset}_pp.h... |
89b3e303c34970ded38740358feee1d94e114b4448c3c59cb7add8cb73154c37 | Python | 898 | 21 | from torch.optim.lr_scheduler import _LRScheduler
class PolyLRScheduler(_LRScheduler):
def __init__(self, optimizer, initial_lr: float, max_steps: int, exponent: float = 0.9, current_step: int = None, clip_lr: float = 1e-5):
self.optimizer = optimizer
self.initial_lr = initial_lr
self.max_s... |
f57a97af3e1b7a9ec39549f69fd83fc01646fdadc00589ce61784df7a08910e2 | Python | 898 | 27 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import tempfile
from scilpy import SCILPY_HOME
from scilpy.io.fetcher import fetch_data, get_testing_files_dict
# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['processing.zip'])
tmp_dir = tempfile.T... |
1f258590ffb0a96da9b9745d636afc10d89d8d21b7608371246fe2d7f05d611f | Python | 899 | 55 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
import anndata
import numpy as np
import scvelo as scv
import pandas as pd
import sys
sys.path.append('../../../')
import velovae as vv
import time
import os
# In[2]:
root = '< your root path >'
dataset = 'IO_EU'
adata = anndata.read_h5ad(f'{root}/data/{dataset}_pp.... |
bd97e8b8fdcf21b9df57191f8a0a1851865ea34a15bc6683bc9cd0794b3219ca | Python | 899 | 49 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
import anndata
import numpy as np
import scvelo as scv
import pandas as pd
import sys
sys.path.append('../../../')
import velovae as vv
import time
import os
# In[4]:
root = '< your root path >'
dataset = 'Braindev'
adata = anndata.read_h5ad(f'{root}/data/{dataset}_... |
c77f98c66a151f0265b670026358f480a146e0c8b5864856aece273800a68d57 | Python | 899 | 31 | import polars as pl
from eir.utils.logging import get_logger
logger = get_logger(name=__name__)
def add_tabular_data_to_df(
df_tabular: pl.DataFrame,
input_df: pl.DataFrame,
ids_to_keep: set[str] | None = None,
source_name: str = "Tabular Data",
) -> pl.DataFrame:
logger.debug(f"Adding tabular d... |
cdf83621915bd756e43ef088b8b724e4d8578e411bf13342532025972f6db520 | Python | 899 | 32 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Mon Jul 16 12:07:14 2018
@author: hromada
"""
from os import listdir
import os
import gzip
import sys
from subprocess import call
from os.path import expanduser
import time
from subprocess import Popen, PIPE
mydir = sys.argv[1]
with open('index_report.log... |
bf9c76239aabb641b45eaf22db2f952717e713aa755399e369793fddbb060ba7 | Python | 900 | 24 | import argparse
import os
import pandas as pd
def main(datadir):
test_path = os.path.join(datadir, "test.txt")
print(f"Processing {test_path}")
test = pd.read_csv(test_path, sep="\t", names=["h", "r", "t"])
test_pred = pd.concat([
test.drop_duplicates(subset=['r', 'h']),
test.drop_... |
d847bc4c616d981b1f0808cbb8f61f1c7503a90b3d041c507cc2d4066d421341 | Python | 900 | 55 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
import anndata
import numpy as np
import scvelo as scv
import pandas as pd
import sys
sys.path.append('../../../')
import velovae as vv
import time
import os
# In[2]:
root = '< your root path >'
dataset = 'Retina'
adata = anndata.read_h5ad(f'{root}/data/{dataset}_pp... |
dddc1f4c63c0db0f211a9ee752b85f410ba8c3efc27bb81ffd70e5da74309eba | Python | 900 | 25 | # -*- coding: utf-8 -*-
import os
import nibabel as nib
import numpy as np
from scilpy import SCILPY_HOME
from scilpy.io.fetcher import fetch_data, get_testing_files_dict
from scilpy.image.volume_metrics import estimate_piesno_sigma
fetch_data(get_testing_files_dict(), keys=['processing.zip'])
def test_estimate_pie... |
1eaa199523509ecb3e3ef2c9a79fb5a58018a514cdf51a015e6113925ebbd9d8 | Python | 901 | 33 | # -*- coding: utf-8 -*-
"""TODO"""
import core.core_global as core
from core.monitor import Monitor
class SpikeMonitor(Monitor):
"""TODO"""
def __init__(self, source, filename, from_gid=0, to_gid=None, every=1):
"""TODO"""
super().__init__(filename)
core.kernel.register_device(self)... |
495db095bfcc88d49fa81da4d1cc5abd6752c9a3a57fbba10c61628a0aa23940 | Python | 901 | 34 | from torch import nn
class SimpleDenseNet(nn.Module):
def __init__(
self,
input_size: int = 784,
lin1_size: int = 256,
lin2_size: int = 256,
lin3_size: int = 256,
output_size: int = 10,
):
super().__init__()
self.model = nn.Sequential(
... |
e039715c28f26be58e2b59b8eca2be9478607c34c8c5314d762370a2985fb6e7 | Python | 901 | 30 | import numpy as np
from musclex.utils.image_data import ImageData
from musclex.utils.settings_manager import SettingsManager
def test_fingerprint_uses_settings_manager_directory(tmp_path):
input_dir = tmp_path / "input"
output_dir = tmp_path / "output"
input_dir.mkdir()
output_settings = output_dir /... |
bb9c7dd3576b3b7f09c2ff7963950dac1424e85951e702c5e4494f241fe65e5a | Python | 902 | 22 | #############################################################################
# Copyright (C) 2020-2026 MEmilio
#
# Authors: Maximilian Betz
#
# Contact: Martin J. Kuehn <Martin.Kuehn@DLR.de>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Li... |
239c7a07ead478228cec010cce633bd80f68e78802113a520ac7057be420712e | Python | 903 | 22 | from .weighted_survival import WeightedSurvival
from typing import Any
class MarginalSurvival(WeightedSurvival):
"""
Marginal (un-adjusted) survival estimator.
Essentially it is a degenerated WeightedSurvival instance without a weight model.
"""
def __init__(self,
survival_model: ... |
25b8696ebf7c71e4537767793e86cf511884f430abf76ef929027f8957030abe | Python | 903 | 31 | """Submit jobs to the BMRC cluster.
"""
import os
def write_job_script(run, queue="short", n_gpus=1, n_cpus=12):
"""Create a job script to submit."""
with open("job.sh", "w") as file:
name = f"hcp-hmm-{run}"
file.write("#!/bin/bash\n")
file.write(f"#SBATCH -J {name}\n")
file.... |
56af2796ed3398561f6173df50c2232fa44c098be8baf4265ccc18c048695725 | Python | 903 | 55 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
import anndata
import numpy as np
import scvelo as scv
import pandas as pd
import sys
sys.path.append('../../../')
import velovae as vv
import time
import os
# In[2]:
root = '< your root path >'
dataset = 'Erythroid'
adata = anndata.read_h5ad(f'{root}/data/{dataset}... |
798289a184386d6130a7d1ae9670632995606bae5b01e78f6bf3006727ade885 | Python | 903 | 37 | #!/usr/bin/env python3
import arbor as A
from arbor import units as U
from util import plot_spikes, plot_network
from unconnected import unconnected
# global parameters
# cell count
N = 5
# total runtime [ms]
T = 1000
# numerical time step [ms]
dt = 0.1
class all2all(unconnected):
def __init__(self, N) -> None... |
7de625d02adefc7b5b80325b14f92ba8438b8ef65b325c231797ca6bbb22ff35 | Python | 903 | 31 | #%%
from pathlib import Path
import h5py
import matplotlib.pyplot as plt
from relaxationColorMap import relaxation_color_map
from matplotlib.colors import ListedColormap
# Load the MATLAB file containing an example T1 map
fn = Path(__file__).parent / 'sampleT1map.mat'
with h5py.File(fn, 'r') as f:
data = {key: f[key]... |
a70e52801474b96a1582430296f2f9745532c05a35e0c173349dd6fb9c7c6c63 | Python | 903 | 33 | """Smooth a surface."""
import SVMTK as svm
from pathlib import Path
if __name__ == "__main__":
print("Start ",__file__)
outdir = Path("results")
outdir.mkdir(exist_ok=True)
pig1 = svm.Surface("../Data/pig.off")
pig1.fill_holes()
# Creating a deep copy
pig2 = svm.Surface(pig1)
p... |
c44f136ce2969fad3e7cf1235dde409fe1beeb74c8a58017161c2f64ec357619 | Python | 903 | 30 | """ Create a 3D mesh given an implicit function"""
import SVMTK as svm
from pathlib import Path
def chair_function ( x, y, z):
x2=x*x
y2=y*y
z2=z*z
x4=x2*x2
y4=y2*y2
z4=z2*z2;
return x4-1.2*x2*y2+3.6*x2*z2-7.50*x2+y4+3.6*y2*z2-7.50*y2+.2*z4-7.50*z2+64.0625-16.0*z*y2+16.0*x2*z
if __name__ == "__main__"... |
d24d406498ef7ee796796f1c8d3c16ea4fa2947e05425b0c01862952d9382d6e | Python | 903 | 31 | """Submit jobs to the BMRC cluster.
"""
import os
def write_job_script(run, queue="short", n_gpus=1, n_cpus=12):
"""Create a job script to submit."""
with open("job.sh", "w") as file:
name = f"ukb-hmm-{run}"
file.write("#!/bin/bash\n")
file.write(f"#SBATCH -J {name}\n")
file.... |
0182d547f427c79973d60ae78fc4d31d7fa1e25ff2e0bdc75006ce4617de8691 | Python | 904 | 43 | #!/usr/bin/python3
#
import numpy as np
class Edge:
def __init__(self, n0, n1):
self.n = (n0, n1) if n0 < n1 else (n1, n0)
self.ele = None
def __eq__(self, other):
return isinstance(other, Edge) and self.n == other.n
def __ne__(self, other):
return not self.__eq__(other)
... |
0709d582c835a386760385f58783fd71340daed1a02810ca0e9a68b0bc5f6153 | Python | 904 | 55 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
import anndata
import numpy as np
import scvelo as scv
import pandas as pd
import sys
sys.path.append('../../../')
import velovae as vv
import time
import os
# In[2]:
root = '< your root path >'
dataset = 'Bonemarrow'
adata = anndata.read_h5ad(f'{root}/data/{dataset... |
112038e778ca15e1da8b2900c628d04a9e10b8e0306e6ab975e80a948a401347 | Python | 904 | 55 | #!/usr/bin/env python
# coding: utf-8
# In[9]:
import anndata
import numpy as np
import scvelo as scv
import pandas as pd
import sys
sys.path.append('../../../')
import velovae as vv
import time
import os
# In[3]:
root = '< your root path >'
dataset = 'Pancreas'
adata = anndata.read_h5ad(f'{root}/data/{dataset}_... |
2a4416c1708b4743412935c9c5683e4e462cfca8ee1515816b9833c926f1368c | Python | 904 | 28 | '''
embeddings::internal.py
Internal functions that embeddings.py depends on. Should not be called
directly.
'''
def critical(ref: str = 'unknown::unknown', msg: str = 'Unspecified critical error encountered.'):
'''
Presents a critical error described in `msg` that occurred in `ref`.
'''
... |
65fb06c53e4f30c417178c6f7109b97756fd42965225ac9324713dd3e159e3d2 | Python | 904 | 31 | from PUMI.engine import BidsPipeline
from PUMI.engine import NestedNode as Node
from nipype import Function
# experiment specific parameters:
input_dir = 'data_in/pumi-unittest' # place where the bids data is located
output_dir = 'data_out' # place where the folder 'BET' will be created for the results of this scrip... |
f9819b2921497caedab9e905e80fb704cdf6bcdbe114b563f5a08cec6f43dd98 | Python | 904 | 29 | """ Separate narrow gaps in the surface mesh """
# TODO: complete
import SVMTK as svm
from pathlib import Path
if __name__ == "__main__":
print("Start ",__file__)
outdir = Path("results")
outdir.mkdir(exist_ok=True)
surf = svm.Surface("../Data/lh-pial.stl")
print( surf.num_self_intersections()... |
19e7c2d99d1ceb77684f684f996a5f0d34ee7f7602d951c73a4e113a4aba46cd | Python | 905 | 36 | #Python program to generate batch file for Ephys analysis processing
import os
from numpy import *
from pylab import *
from string import *
import glob
from pprint import pprint as pp
#######################################################
#Edit this part to indicate which files and which molecules
#Use glob on the .x... |
7433b7a85a87ead4b03a39f65c8231e6a0194e667e67a2306521e36e6cd91f9e | Python | 905 | 30 | import subprocess
import nibabel
from nibabel.spatialimages import SpatialImage
from pathlib import Path
def load_nibabel_spatial(input: str | Path) -> SpatialImage:
im = nibabel.load(input)
assert isinstance(im, SpatialImage), f"File {input} is not a nibabel SpatialImage."
return im
def mri_number_of_f... |
8be61a2a787253c5d99dfdee98c4c46968be89f6dbf75e26ad3b2b91cff32411 | Python | 905 | 55 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
import anndata
import numpy as np
import scvelo as scv
import pandas as pd
import sys
sys.path.append('../../../')
import velovae as vv
import time
import os
# In[2]:
root = '< your root path >'
dataset = 'Neuron_scNT'
adata = anndata.read_h5ad(f'{root}/data/{datase... |
d701cf9ead8e79bf9e7d67f8854b75e0133c4a1cb8a09362d88b73c9fc607df1 | Python | 905 | 23 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
from ultralytics.models.yolo.segment import SegmentationTrainer
from .train import YOLOEPETrainer, YOLOETrainer, YOLOETrainerFromScratch, YOLOEVPTrainer
class YOLOESegTrainer(YOLOETrainer, SegmentationTrainer):
"""Trainer class for YOLOE segmen... |
f1d9f5e6a987825df270a7f54710a69f9c2e8f8f97359e7e92aec62ce0e6f5e5 | Python | 905 | 34 | """Make a list of the data files we want to train on.
"""
import os
import scipy.io
from tqdm.auto import trange
# %% Subject IDs
# Load matlab file containing subject IDs
mat = scipy.io.loadmat(
"/gpfs3/well/win-biobank/projects/imaging/data/data3/ANALYSIS/workspace13d.mat",
only_include="subject_IDs_uniqu... |
2e0dc43a2002096833e3f5d5fad22e364d3d2c3f011d8cd0af9fbb2a97e74b95 | Python | 906 | 36 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
from typing import Any
import attrs
from cvat_sdk.api_client import models
from shared.tasks.interface import ITaskSpec
from shared.tasks.utils import parse_frame_step
@attrs.define
class TaskSpecBase(ITaskSpec):
_params: dict | models.TaskWr... |
5d05362359b13ed8feebc1f1512af19e229bff0f4905e644dbbb05bf8efaf822 | Python | 906 | 27 | import pandas as pd
import csv
labels = pd.read_csv("/data2/whr/czl/TwiBot22-baselines/datasets/cresci-2015/label.csv")
user_final = []
for row in labels.iterrows():
user_final.append(row[1][0])
df = pd.read_csv("/data2/whr/czl/TwiBot22-baselines/datasets/cresci-2015/edge.csv")
user_to_post = {}
for row in df.it... |
71f8ee669e27b79ce09f3de0d94a57a0667906baddc7088ca65ee97d2402be78 | Python | 906 | 26 | #!/usr/bin/env python3
import nibabel as nib
import numpy as np
import os
from dipy.denoise.nlmeans import nlmeans
from dipy.denoise.noise_estimate import estimate_sigma
# ==== 输入输出 ====
in_file = "/mnt/f/BIDS/demo_BIDS/derivatives/xfm/sub-AFib0241/ses-baseline/sub-AFib0241_ses-baseline_acq-highres_desc-brain_T1w.nii.... |
737b597e961434960cd0dbd9bd890eab43d903b1f30566be9fdfeff3f0be355d | Python | 906 | 35 | import os
import platform
import subprocess
from pathlib import Path
_BRAINWAYS_PATH = Path.home() / ".brainways"
def get_brainways_dir() -> Path:
if not _BRAINWAYS_PATH.exists():
_BRAINWAYS_PATH.mkdir()
return _BRAINWAYS_PATH
def get_brainways_config_path():
return _BRAINWAYS_PATH / "brainways... |
7ea6999a0fca29df052b5a3f20e510f82649d164a83ad9e031a94551d038dd5e | Python | 906 | 27 | import pandas as pd
import csv
labels = pd.read_csv("/data2/whr/czl/TwiBot22-baselines/datasets/cresci-2017/label.csv")
user_final = []
for row in labels.iterrows():
user_final.append(row[1][0])
df = pd.read_csv("/data2/whr/czl/TwiBot22-baselines/datasets/cresci-2017/edge.csv")
user_to_post = {}
for row in df.it... |
9e5be1274774fe5728f1abe60a73bbdc937cc3930b08a83b83a531ee07ea7490 | Python | 906 | 55 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
import anndata
import numpy as np
import scvelo as scv
import pandas as pd
import sys
sys.path.append('../../../')
import velovae as vv
import time
import os
# In[2]:
root = '< your root path >'
dataset = 'Dentategyrus'
adata = anndata.read_h5ad(f'{root}/data/{datas... |
e3c5063c64f1816a428cd21972bd761697ecd901b672a117c379a09a9577d766 | Python | 906 | 29 | # 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, ... |
bc4ac5e7f18e4234299fa824a160488618ba12edcad93290a7b7040d8d2cba53 | Python | 907 | 33 | import numpy as np
AALETTER = [
'A', 'R', 'N', 'D', 'C', 'Q', 'E', 'G', 'H', 'I',
'L', 'K', 'M', 'F', 'P', 'S', 'T', 'W', 'Y', 'V', 'X']
AANUM = len(AALETTER)
AAINDEX = dict()
for i in range(len(AALETTER)):
AAINDEX[AALETTER[i]] = i + 1
INVALID_ACIDS = set(['U', 'O', 'B', 'Z', 'J', '*'])
MAXLEN = 1000
def ... |
d7befadb606dd588e3a432fd878f129597c9fa1d5ce080dc6c848cef30324dc3 | Python | 907 | 39 | # -*- coding: utf-8 -*-
# external inputs
import nibabel as nb
def multiply_images(file1, file2, file_out):
"""Multiply images.
This script does voxewise multiplication of two images. The output image
takes the header information of the first image.
Parameters
----------
file1 : str
... |
13093f90b52090f7938a7dceda71e2932d7ab056310db6958ebe1855f3d2ecc9 | Python | 908 | 47 | from pathlib import Path
import click
from brainways.project.brainways_project import BrainwaysProject
@click.command()
@click.option(
"--project",
"project_path",
type=Path,
required=True,
help="Brainways project path.",
)
@click.option("--condition", required=True)
@click.option("--values", re... |
27e52e8d9270a7336a418bb381f58b39bae6aaeda02124d85b84ef6bc2a90451 | Python | 908 | 27 | """The package's two version strings must agree.
`surface_morphometrics.__version__` and `pyproject.toml`'s `version` have drifted
apart twice (fixed in 2.0.0b3, drifted again at 2.0.0b5) because a release bumps one
and forgets the other. This pins them together.
"""
import os
import tomllib
import pytest
import sur... |
ce81a14d90ca5b24cd6086472f63691857b7bdde47fb3d03656224caee89330c | Python | 908 | 55 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
import anndata
import numpy as np
import scvelo as scv
import pandas as pd
import sys
sys.path.append('../../../')
import velovae as vv
import time
import os
# In[2]:
root = '< your root path >'
dataset = 'Hindbrain_pons'
adata = anndata.read_h5ad(f'{root}/data/{dat... |
f832ff7abe05100e69972581ff57a930fd8d78b6c2b0383b5d6c84b8883872b6 | Python | 909 | 55 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
import anndata
import numpy as np
import scvelo as scv
import pandas as pd
import sys
sys.path.append('../../../')
import velovae as vv
import time
import os
# In[2]:
root = '< your root path >'
dataset = 'Erythroid_Human'
adata = anndata.read_h5ad(f'{root}/data/{da... |
4e3f79439f8b46724a2eaac6334b3e714efc16b17018226f569032c7e97dd8d1 | Python | 910 | 32 | import numpy as np
__all__ = ['truncate_video_to_pulse']
def truncate_video_to_pulse(track_res: np.ndarray,
camera_time: np.ndarray) -> np.ndarray:
"""
Truncate the video frame number in a tracking result to match with the camera event pulse.
Only Applicable if the tracked res... |
f187803be8eb3b5498b3dcc9210ccbd240dd47690b71d8716a4cf5f747b89153 | Python | 910 | 31 | import pandas as pd
import polars as pl
from neuralib.typing import DataFrame
from rscvp.util.util_gspread import (
GSPREAD_SHEET_PAGE,
RSCGoogleWorkSheet,
filter_tdhash,
skip_comment_primary_key
)
__all__ = ['as_validate_sql_table']
def as_validate_sql_table(df: DataFrame, src_page: GSPREAD_SHEET_P... |
28c14159b044a16effa3c0133a578d5ae66ea50477d4fd40a33bc0e414c2386b | Python | 911 | 32 | import numpy as np
def coordinates_to_voxels(coords, resolution=(10, 10, 10)):
"""Find the voxel coordinates of spatial coordinates
Parameters
----------
coords : array
(n, m) coordinate array. m must match the length of `resolution`
resolution : tuple, default (10, 10, 10)
Size o... |
72ffdfee063cde04e257fae4cd381a4a9bb892026c3eb356783e08e7f8b1b53e | Python | 911 | 32 |
from __future__ import absolute_import
import tensorflow as tf
from tensorflow.keras.layers import Layer
def drop_path_(inputs, drop_prob, is_training):
# Bypass in non-training mode
if (not is_training) or (drop_prob == 0.):
return inputs
# Compute keep_prob
keep_prob = 1.0 - drop_prob... |
9a5ad1c5c4f55c5b99639bee7252c08e346ad9786afa1309e3cd9ae399d7481e | Python | 911 | 25 | #############################################################################
# Copyright (C) 2020-2026 MEmilio
#
# Authors: Daniel Abele
#
# Contact: Martin J. Kuehn <Martin.Kuehn@DLR.de>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Licen... |
a52f1c55469d14ce7701636f90e8565d1b8fa0187e824bc348d8a8a1ee4052fc | Python | 911 | 25 | import pandas as pd
# restrict analysis to regions showing variability in 5% of sample
# https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6866937/
# “sufficient affection” as 5% of the whole sample
def filter_columns(input_file, output_file, threshold=0.05):
# Read the tab-separated value file into a DataFrame
df... |
b6ce360eb66e3ebfd225261cf3ad8589adc5318406f0e0496e057b1d3942cded | Python | 911 | 34 | from __future__ import annotations
import pytest
# Skip when the optional 'academy' extra is absent. The event_log
# module itself is pure stdlib, but the import guard is applied
# uniformly across the academy test suite.
pytest.importorskip("academy")
from chemgraph.academy.observability.event_log import EventLog, ... |
1c6ecda3352345425c9f651d3c2e91caa6126f409821c12f5baf6db247986c6e | Python | 912 | 21 | from setuptools import setup
setup(
name = "NeuralCompresion_v3",
version = "0.0.1.dev",
author = "Yi Huang",
author_email = "yhuang2@bnl.gov",
description = ("Time projection chamber data compression "
"with bicephalous convolution autoencoder "
... |
288796f3f75d6dd062f44990c70bb51e47ff6f98537d13ba35b4a2c474ffeafe | Python | 912 | 26 | import pytest
from brainscore_vision import load_stimulus_set
@pytest.mark.private_access
@pytest.mark.slow
class TestImagenetC:
def test_noise(self):
stimulus_set = load_stimulus_set('imagenet_c.noise')
assert len(stimulus_set) == 3 * 5 * 50000
assert len(set(stimulus_set['synset'])) == 1... |
6d64f0f556adc9687a8364a90717ebabd864640e7762ba91bf3cca20dd12722b | Python | 912 | 28 | import OptimalBattery.simulate as sim
import torch as pt
import os
device = pt.device('cuda' if pt.cuda.is_available() else 'cpu')
# start with some U_true, in this simulation 5 parcels
height = 30
width = 30
K_main = 5
U_true_5 = sim.make_U_spatial(height, width, K_main)
U_true_5 = pt.tensor(U_true_5,device=device, ... |
b6119c3972869d6e77e1ab4e68a9586d182fbd17b2424e3b8e30821d6483150d | Python | 913 | 27 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import tempfile
from scilpy import SCILPY_HOME
from scilpy.io.fetcher import fetch_data, get_testing_files_dict
# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['atlas.zip'])
tmp_dir = tempfile.Tempor... |
2faf2d062eab949fec9dc0a42ef505d73216b282896c9c80b0ae660f5f3d3bff | Python | 914 | 29 | import re
from pathlib import Path
from typing import Union
from paquo.images import ImageProvider
from paquo.projects import QuPathProject
from brainways.utils.io_utils.file_iterators.image_entry import ImageEntry
from brainways.utils.io_utils.readers.czi import CziReader
class QuPathFileIterator:
def __init__... |
a03ce253311c3cd7dd0026afb2349f7dd37f8407fe09ec29f99bcb1846d930ba | Python | 914 | 26 | import numpy as np
import rsatoolbox
import scipy.stats
import matplotlib.pyplot as plt
import met_brewer
from matplotlib.colors import LinearSegmentedColormap
cm = "crossnobis"
smooth = "unsmooth"
rdms_movie = rsatoolbox.rdm.rdms.load_rdm(f"./all_rdms/rdms_{cm}_{smooth}.pkl")
for time in [0.084, 0.232]:
topred = ... |
c6e8f045cd1a9092287b463225e7c0e1f4b7bddd8b3558a39aae80677dfcc07d | Python | 915 | 23 | #############################################################################
# Copyright (C) 2020-2026 MEmilio
#
# Authors: Agatha Schmidt, Henrik Zunker
#
# Contact: Martin J. Kuehn <Martin.Kuehn@DLR.de>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in complian... |
3c6e77fbe59224c6fb7f690776627d03ef480a6a77bce1e1c1985e8ac1bafe1e | Python | 916 | 26 | from __future__ import annotations
import PIL.Image
from PySide6 import QtGui
from pytestqt.qtbot import QtBot
from labelme._widgets._brightness_contrast_dialog import BrightnessContrastDialog
def test_sliders_expose_names_values_and_keyboard_steps(*, qtbot: QtBot) -> None:
dialog = BrightnessContrastDialog(
... |
9b303d6edf302ff7868dab8af037c2716fa412d965b3987e80f35351691f9745 | Python | 916 | 42 | import amc_parser as amc
from glob import glob
import numpy as np
import pickle as pkl
# BASE_DIR = 'data'
# asf_name = '35.asf'
BASE_DIR = '.'
asf_name = '09.asf'
joints = amc.parse_asf(BASE_DIR + '/' + asf_name)
joints['root'].get_name_to_idx()
edges = joints['root'].output_edges()
print('All edges:', len(edges))
... |
b9f9286227c8f1ebdff720f9712ebf2a1c9c2234e5a6a814cb9c1da489c3abc4 | Python | 916 | 32 | import yaml
import sys
class Setting(object):
def __init__(self,pathpath = 'PATHS/general_paths.yml',exptype='Passive'):
with open(pathpath, 'r') as f: self.pdict = yaml.safe_load(f)
workdir = self.pdict['workspace_dir']
if not workdir in sys.path:
print('Appending sys %s'%wor... |
fe47055c5831f20fd3aa34bb8003320792c2e11752b37f38cc780f3dff1fcbd8 | Python | 916 | 25 | #############################################################################
# Copyright (C) 2020-2026 MEmilio
#
# Authors: Daniel Abele
#
# Contact: Martin J. Kuehn <Martin.Kuehn@DLR.de>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Licen... |
81703d0e5a16fb73415498bd6b74d56b20ab18fe266ee0a7c76fa94da8d7f521 | Python | 917 | 31 | """
Read sequence lengths from a file. Each line is of the form <name> <length>
where <name> is typically a chromsome name (e.g. chr12) and length is the
number of bases the sequence.
"""
def read_lengths_file(name):
"""
Returns a hash from sequence name to length.
"""
chrom_to_length = {}
f = o... |
2b632e3ca82144ec4fe8508db4e6c6cb1e98e3bebd6d1e742faa6cf022aa9762 | Python | 918 | 24 | import setuptools
with open("README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name="SpaGCN",
version="1.2.7",
author="Jian Hu",
author_email="jianhu@pennmedicine.upenn.edu",
description="SpaGCN: Integrating gene expression and histology to identify spatial domains and sp... |
446fd1b309f0447d5267315820318d92d2367855eeb71877b0efdf7c897aa2fa | Python | 918 | 32 | class Dimension:
def __init__(self, index: int, name: str, size: int):
"""
Initialize the Dimension object.
:param index: The integer index of this Dimension.
:param name: The user-provided name of this Dimension.
:param size: The user-provided size of this Dimension.
... |
7851fd639727904720df722e1038099d5b71043516dcf9c3cd62cf638caf51df | Python | 918 | 25 | #############################################################################
# Copyright (C) 2020-2026 MEmilio
#
# Authors: Daniel Abele
#
# Contact: Martin J. Kuehn <Martin.Kuehn@DLR.de>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Licen... |
9097566c638d7f36530f99ce92d57db7435b2074c6b8b3aad058e5e9786af45e | Python | 918 | 21 | from torch.optim.lr_scheduler import _LRScheduler
class PolyLRScheduler(_LRScheduler):
def __init__(self, optimizer, initial_lr: float, max_steps: int, exponent: float = 0.9, current_step: int = None, clip_lr: float = 1e-5):
self.optimizer = optimizer
self.initial_lr = initial_lr
self... |
82dd1b4811ed52d7f82641ee040de42da75743dfea0e6bd8f78507e3f388fc99 | Python | 919 | 27 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import tempfile
from scilpy import SCILPY_HOME
from scilpy.io.fetcher import fetch_data, get_testing_files_dict
# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['tractometry.zip'])
tmp_dir = tempfile.... |
a4e60a4edf5cfded1623112022fc8464663b95469a2f13468aa50d56e53fad9b | Python | 919 | 32 | """Contains constants used for sequences and sequence models."""
# Header for BLAST output file using outfmt 6 (https://www.metagenomics.wiki/tools/blast/blastn-output-format-6)
BLAST_HEADER = [
'qseqid',
'sseqid',
'pident',
'length',
'mismatch',
'gapopen',
'qstart',
'qend',
'sstart'... |
cf3591de13675d53a7ea5bd96a398f81ff0e784687ed326d0ba41bab1f85310f | Python | 919 | 25 | #############################################################################
# Copyright (C) 2020-2026 MEmilio
#
# Authors: Maximilian Betz
#
# Contact: Martin J. Kuehn <Martin.Kuehn@DLR.de>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Li... |
4d9b25b977884e9a77043566b2b12746d7c695ea481c0adedeac0c450331601a | Python | 920 | 19 | """A collection of preprocessing utilities.
# TODO: These contents don't all exist yet, sketching this out based on
# the strfy proposal document.
Contents:
`spectrogram`: Convert sound waveforms to spectrograms.
`filters.py`: Transform data using smoothing, high-pass filter, etc.
`normalization.py`:... |
530057273a4ad8a7674d6625bb16ea138d1e2818ab8a8a195ba979eaeeb46c92 | Python | 920 | 35 | from pathlib import Path
from click.testing import CliRunner
from brainways.scripts.cli import cli
from brainways.utils.atlas.brainways_atlas import BrainwaysAtlas
# def test_cell_detection(
# project_path: Path, test_image_size: ImageSizeHW, tmpdir
# ):
# runner = CliRunner()
# CellDetector.run_cell_det... |
697857d6b6d89cf72b82ecbbfa1b2b78fd1fcef43fd4ac81c4d20ca87b97c9de | Python | 920 | 25 | #############################################################################
# Copyright (C) 2020-2026 MEmilio
#
# Authors: Daniel Abele
#
# Contact: Martin J. Kuehn <Martin.Kuehn@DLR.de>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Licen... |
a476a5467d55a458e0fe0256fc20ab43f0729278b8ddddec549a1ce3b89078ff | Python | 920 | 47 | # Preprocessing
from .preprocessing import (
load_dataset,
split_data,
scale_features,
extract_gene_pathway,
build_gene_matrix,
cells_to_numpy,
load_numpy_arrays,
convert_to_cnn2d_input,
save_numpy_arrays
)
# Deep Learning Models
from .model import (... |
17d653f25b4a04f653491c6b15994c4d19775f55a1a57a2bba4d109389b87508 | Python | 921 | 38 | # -*- coding: utf-8 -*-
"""TODO"""
import numpy as np
import core.core_global as core
from core.core_definitions import simulation_timestep
from core.spiking_group import SpikingGroup
class PoissonGroup(SpikingGroup):
"""TODO"""
def __init__(self, size, rate=1.0):
"""TODO"""
super().__init_... |
46fd299dec4ef218e6c16259d2ae4c4a117fdd71ea7200591168e5f6db7cc5ad | Python | 921 | 23 | """General Linear Model (GLM) and permutation testing.
Modules
-------
- :py:mod:`~osl_dynamics.glm.base` — :py:class:`DesignConfig` for specifying
regressors/contrasts and :py:class:`GLM` for fitting the model.
- :py:mod:`~osl_dynamics.glm.ols` — Ordinary least squares implementation.
- :py:mod:`~osl_dynamics.glm.p... |
98423013c87b462fb420863ac4d5533b4ce6753860628208489529e8c1baef81 | Python | 921 | 23 | #############################################################################
# Copyright (C) 2020-2026 MEmilio
#
# Authors: Daniel Abele
#
# Contact: Martin J. Kuehn <Martin.Kuehn@DLR.de>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Licen... |
c84a48ff178aeac21c082935a6e9af4f1b725797560bcd107e9bc0b9e1a435f5 | Python | 921 | 25 | #############################################################################
# Copyright (C) 2020-2026 MEmilio
#
# Authors: Maximilian Betz
#
# Contact: Martin J. Kuehn <Martin.Kuehn@DLR.de>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Li... |
ddf2d8654921cf85a175b8eb17ebe1fa490d1c1d5f3c0a096e37d66437a0acdf | Python | 921 | 37 | from analognasbench.data import AnalogNASBench
# Initialize
benchmark = AnalogNASBench()
# Query a specific metric for an architecture
# Availible metrics :
# baseline_accuracy
# ptq_accuracy
# qat_accuracy
# noisy_accuracy
# analog_accuracy
# noisy_drift_60
# analog_drift_60
# noisy_drift_3600
# analog_drift_3600
#... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.