sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
d3dead76c880f1b4d6bbb50270d558e5010e1b5176eb0110709d080d346722d3 | Python | 1,288 | 42 | """Calculate HMM state spectra using a multitaper."""
import os
import pickle
from osl_dynamics.data import Data
from osl_dynamics.analysis import spectral
def get_data(name, rename):
os.system(f"osf -p by2tc fetch data/{name}.zip")
os.makedirs(rename, exist_ok=True)
os.system(f"unzip -o {name}.zip -d {re... |
dfae33ff7b453fefc66f112aa238471dffe1ae9cd48acebc8d2ba5e68eb6e99e | Python | 1,288 | 42 | import os
import sys
sys.path.insert(0, os.path.abspath(".."))
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Project information ---------------------------... |
6f4a6af5517866703ba788749d9763558ff1d1e998461052cad116989dcf5b3e | Python | 1,289 | 39 | from ._hit_testing import nearest_edge_index
from ._hit_testing import nearest_rotation_point_index
from ._hit_testing import nearest_vertex_index
from ._merge import can_merge_shapes
from ._merge import merge_masks
from ._model import CIRCLE_POINT_COUNT
from ._model import LINE_POINT_COUNT
from ._model import MIN_LINE... |
31acfc5d9b630f76226776961eaf1fb5043786ec7b373ae02705760450a81965 | Python | 1,290 | 50 | import dipy.tracking.streamlinespeed as dps
import numpy as np
def sl_curve(sl, n_points):
"""
Calculate the direction of the displacement between
each point along a streamline
Parameters
----------
sl : 2d array-like
Streamline to calculate displacements for.
n_points : int
... |
9863835b5922d5ce9fab328be9465c83cf1afac341871b4592520f39a704793a | Python | 1,290 | 34 | from brainscore_core.supported_data_standards.brainio.assemblies import NeuronRecordingAssembly
from brainscore_vision import data_registry, stimulus_set_registry, load_stimulus_set
from brainscore_core.supported_data_standards.brainio.s3 import load_assembly_from_s3, load_stimulus_set_from_s3
BIBTEX = """@article{da... |
fcb643c1bffce94cef79657937cd7a25bc1113250fc77d1725f57363a24c8323 | Python | 1,290 | 36 | import torch
from torch import Tensor
import torch.nn as nn
from typing import Union, List
from bism.utils.cropping import crop_to_identical_size
class jaccard(nn.Module):
def __init__(self):
super(jaccard, self).__init__()
def forward(self, predicted: torch.Tensor, ground_truth: torch.Tensor,
... |
352c7fb7166e184a8b1f17d27e557f64264947ba670e6c78e39b739e47f1f162 | Python | 1,291 | 58 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
# In[12]:
import anndata
import numpy as np
from deepvelo.utils import velocity, velocity_confidence, latent_time, update_dict
from deepvelo.utils.preprocess import autoset_coeff_s
from deepvelo.utils.plot import statplot, compare_plot
from deepvelo import train, Consta... |
483fa40c8598db2df2e59afe960874d1073592998305d8de76a83098423e925d | Python | 1,291 | 38 | import os
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
import numpy as np
from pathlib import Path
def get_middle_slice(tensor):
# Ensure there's at least one slice to display
if tensor.shape[0] > 0:
return tensor[tensor.shape[0] // 2]
return tensor[0] # Default to th... |
8359368b16e723e2b507fe3ff04ed27b814150d86d05dbc939df8297bc4eea59 | Python | 1,291 | 41 | from scipy.stats.qmc import Sobol, scale
import numpy as np
import pandas as pd
import os
# Set number of dimensions and samples
dim = 25
seednum = 42
n_samples = 131072 # Initial samples 2^17
output_file = "sobol_samples_Hab6_global.csv"
# Load existing samples if available
if os.path.exists(output_file):
df_ex... |
a2c8658c2ac72d0660eb71755f1829ac0b6b26de445adb760181e89240258f04 | Python | 1,291 | 41 | from scipy.stats.qmc import Sobol, scale
import numpy as np
import pandas as pd
import os
# Set number of dimensions and samples
dim = 25
seednum = 42
n_samples = 131072 # Initial samples 2^17
output_file = "sobol_samples_Rew1_global.csv"
# Load existing samples if available
if os.path.exists(output_file):
df_ex... |
a6f9d33ba5d3ba598d9080b0a507fc60710731ea352ea2181a643d8fbd434f01 | Python | 1,291 | 41 | from scipy.stats.qmc import Sobol, scale
import numpy as np
import pandas as pd
import os
# Set number of dimensions and samples
dim = 25
seednum = 42
n_samples = 131072 # Initial samples 2^17
output_file = "sobol_samples_Hab1_global.csv"
# Load existing samples if available
if os.path.exists(output_file):
df_ex... |
caa09b8e5a2d9a5b6c39e600efbe9904f008ad957663da86c8da2de5d842ed6f | Python | 1,291 | 41 | from scipy.stats.qmc import Sobol, scale
import numpy as np
import pandas as pd
import os
# Set number of dimensions and samples
dim = 25
seednum = 42
n_samples = 131072 # Initial samples 2^17
output_file = "sobol_samples_Rew6_global.csv"
# Load existing samples if available
if os.path.exists(output_file):
df_ex... |
cc27819ea1718cc0ede8752af9db5e3bfe2e9e9f454a01839517cbc9484b033d | Python | 1,291 | 49 | import os
import glob
from tqdm import tqdm
import imageio
import h5py
from micro_sam.automatic_segmentation import (
get_predictor_and_segmenter,
automatic_instance_segmentation,
)
from nicety.conf import get_conf
from fiberpipeline.utils import preprocess_vol, get_basename
from tqdm import tqdm
def segmen... |
dad4f2dd78060e23e17ac53f9f3eb20ae99199d5121a49ca03f06d6329a09ae9 | Python | 1,291 | 36 | # Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master... |
282524dd90289bc997e3158b083e02f648a50b6c7d43859ce47288107d023426 | Python | 1,292 | 39 | from __future__ import print_function as _, division as _
import numpy as np
import csv
def readcsv(fname):
data=[]
with open(fname) as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
for row in csv_reader:
data.append(row)
neurnames=[name for name in data[0] if len(n... |
346a7ee9ad4d8f10477d688363892cb7faa2db100f9612cd3ff93fb1fe383762 | Python | 1,292 | 41 | import os
import numpy as np
import torch
from ecg_utils import get_dataloaders
print("Initializing train_loader...")
train_loader, _, _, _ = get_dataloaders(
batch_size=128,
mode='1D',
sampling_rate=100,
label_set="3",
work_num=4,
return_sample_ids=False,
cus... |
5abc125902dd6e7a3bf122500ec60119c3ff04cb3d525c6b5358646b1973f62f | Python | 1,292 | 36 | # 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
# distributed under th... |
9d921d8beb159d1a4f39d1b1841b4f8f5bca24d324c45b01274b87b7d0da0106 | Python | 1,292 | 40 | import logging
import os
import sys
def setup_logger(name="cvdproc", log_file=None, level=logging.DEBUG):
"""
Configure and return a consistent logger instance.
:param name: str, logger name
:param log_file: str, optional log file path (if provided, logs are also written to the file)
:param level:... |
abc374df92f645c6fb26cfe91f5cdc740591e12fbdcea8ca91b44fd62600878e | Python | 1,292 | 51 | import pandas as pd
import numpy as np
import getopt
import sys
def split_gem_Usage():
print("""
Usage : split_gem.py -i <input.gem>
-o <output.gem>
-x <X of split>
-y <Y of split>
Notice: There's only -x or -y
""",flush=True)
def split_gem_main(arg... |
ae92f3b43f1debb899d051006c5a104e70af15ed2080713679949d103db45084 | Python | 1,292 | 51 | #!/usr/bin/env python
"""
Convert wiggle data to a binned array. This assumes the input data is on a
single chromosome and does no sanity checks!
usage: %prog score_file out_file < wiggle_data
-c, --comp=type: compression type (none, zlib, lzo)
"""
import bx.wiggle
from bx import misc
from bx.binned_array import... |
d646427983dada887f7ebcf088415ae6fb2169f4781f55e4368a722701800318 | Python | 1,292 | 36 | import setuptools
import os
with open("README.md", "r") as fh:
long_description = fh.read()
requirements = [
'wbuild>=1.8.0',
'python-dateutil',
'pandoc',
'graphviz',
'pandas>=3.0',
]
extra_files: list[str] = []
for (path, directories, filenames) in os.walk('drop/'):
directories[:] = [d f... |
b611a50cfa216297470f01b767bd0b0647b2c6447392c9dc6048e781bc5f481a | Python | 1,293 | 33 | #!/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=['bundles.zip'])
tmp_dir = tempfile.Temp... |
db096c5fcc2df353c9e69c2aee8a327d54ac42d492b6ef4d3766988f151632c9 | Python | 1,293 | 43 | # Generated by Django 4.2.15 on 2024-08-21 13:56
from django.db import migrations, models
import cvat.apps.quality_control.models
class Migration(migrations.Migration):
dependencies = [
("quality_control", "0002_qualityreport_assignee"),
]
operations = [
migrations.AddField(
... |
4214d511fab73820d2a5c13ee9dbb9b8a8f1a7921a3cc822971546f3729102b5 | Python | 1,294 | 39 | from .config import get_config
from .references import get_reference, get_fallback_reference, parse_reference_path, get_ref_from_templateflow
from .plotting import plot_roi, segmentation_qc_plot, coregistration_qc_plot, timeseries_carpet_plot
from .image_transformations import scrub_image, scale_vol, registration_ants_... |
8d9cf946dab02580aa5f8e084fd97712e12e1441289f9787bcf6d50993cb4d99 | Python | 1,294 | 43 | # -----------------------------------------------------------------------------
# Copyright © 2009- The Spyder Development Team
#
# Licensed under the terms of the MIT License
# (see LICENSE.txt for details)
# -----------------------------------------------------------------------------
"""Provides QtDataVisualization... |
5ffcab6134c2994d67c8f65b5d9df3b635f2f2906d671141a1497572a0bbe7a7 | Python | 1,295 | 31 | import tensorflow as tf
import matplotlib.pyplot as plt
import os
# 读取图像的原始数据
# image_raw_data = tf.gfile.FastGFile("./images/000b7d55b6184b08.png", 'rb').read()
file = 'TI_VGG19/'
with tf.Session() as sess:
file_name_list = os.listdir(r'D:\desktop\fsdownload\first-second_1')
print(file_name_list)
for image... |
b3847f61a9e908d08a7ae232ab4be075628445934d7c5b3833bb0229a3e1d39d | Python | 1,295 | 40 | import math
import torch
from torch.nn.parameter import Parameter
from torch.nn.modules.module import Module
class GraphConvolution(Module):
"""
Simple GCN layer, similar to https://arxiv.org/abs/1609.02907
"""
def __init__(self, in_features, out_features, bias=True):
super(GraphConvolution, ... |
48811bcfcf1f5ed534ca1786bb16a868e85032100c0ccd796f7ea7e56e433254 | Python | 1,296 | 43 | """Example code for creating a sensor space topoplot.
"""
import numpy as np
from osl_dynamics import files
from osl_dynamics.utils import plotting
# Scanner channel names
ctf275_channel_names = np.load(files.scanner.path / "ctf275_channel_names.npy")
# N.b. that if you are reading in a cell array of file names fro... |
5e00818a2f54503407af0301b6fe574fecdbe689792726acae0f54f21fdd8bb3 | Python | 1,296 | 34 | #!/usr/bin/env python3
import os
import argparse
def replace_spaces_with_underscores_in_folder_names(folder_path):
"""
遍历指定文件夹及其所有子文件夹,将文件夹名称中的空格替换为下划线
:param folder_path: str, 需要处理的根文件夹路径
"""
for root, dirs, _ in os.walk(folder_path, topdown=False):
for dir_name in dirs:
origi... |
6603f14aae2c76dcfd00a78b569dce430ec2f6ca254eee548057241efd771bef | Python | 1,296 | 40 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
from ultralytics.utils import SETTINGS
try:
assert SETTINGS["raytune"] is True # verify integration is enabled
from ray import tune
assert hasattr(tune, "get_context") # verify Ray>=2.41 Tune API, also required by tuner.run_ray_tune
ex... |
92e3e7f145e3199f245fc54cffa799f42c2589dd982b78b8caa3cac6a379442d | Python | 1,296 | 43 | from pydantic import BaseModel, Field
from container import Container
from model.base_dao import BaseDao
from model.bsom_object import PyObjectId
from bson.objectid import ObjectId
class UserModel(BaseModel):
id: PyObjectId = Field(alias="_id", default=None)
username:str
email: str
password: str
... |
9fceda3034895b73d3ebb5596416052fdd6833016ec5db762ee80e13c0bca0e4 | Python | 1,296 | 48 | import numpy as np
import pandas as pd
import os
from trial import Trial
class Dataset:
'''
'''
def __init__(self, pid: str, path: str):
'''
'''
# set paths
self.pid = pid
self.path = path
self.out = os.path.join(self.path, pid + '.csv')
#... |
b5107ca214611ccb10e73534c703b8221de82727083887c4cc8a02c870fc2c38 | Python | 1,296 | 52 | # -*- coding: utf-8 -*-
"""
Created on Mon Sept 04 2023
@author: axthi
"""
import sys
# --------------------------------------------------
# NOTE: Update this path to fit to your installation
path_to_utils = 'C:/Users/axthi/simnibsN/memoslap_utils/'
sys.path.append(path_to_utils)
from simnibs_memoslap_utils.utils imp... |
38977cd271641d782d128632a40511952dace69b84e42c8c80c027bee9d4d987 | Python | 1,297 | 47 | import argparse
import pandas as pd
def main(args):
print(f"Read result file from {args.res}")
res_file = pd.read_csv(args.res, sep="\t")
print(f"Read vtk file from {args.vtk}")
with open(args.vtk, "r") as input:
tempB = input.readlines()
args.col_name = args.col_name.split(",")
for ... |
4143fe95169d0526ba5c7b513cb05cd9e062bd8ff3a700f4af7ad17d57d4b964 | Python | 1,297 | 54 | from impedancefitter.randles import Z_randles_CPE, Z_randles
from impedancefitter import get_equivalent_circuit_model
import numpy as np
omega = 2. * np.pi * np.logspace(1, 8, num=20)
# for randles
Rct = 100.
Rs = 100.
Aw = 10.
C0 = 1e-6
# for randles_CPE
k = 1e-5
alpha = 0.6
model1 = 'R_s + parallel(R_ct + W, C)'
... |
5daeca86410c0145bb3771511802fdd7edbb66e1346ba46a584edc5178da190f | Python | 1,297 | 38 | import os
import json
import torch
import pandas as pd
import numpy as np
from tqdm import tqdm
from pathlib import Path
path1 = Path('datasets/Twibot-22/node.json')
with open(path1, 'r') as f:
nodes = json.loads(f.read())
nodes = pd.DataFrame(nodes)
users = nodes[nodes.id.str.contains('^u')]
tweets = ... |
641ee124f224cd266b3fdbe4491434ddb38234f040bc4925e9f744f3aacfccb1 | Python | 1,297 | 36 | # This file is part of Mooney computational modeling project.
#
# Mooney computational modeling project is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) an... |
94a00184f100e4f9afe07d98f09c07fb57009e2765172a53d8c10604e1dcec0d | Python | 1,297 | 32 | # Copyright (c) DP Technology.
# 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.
from unicore.optim.lr_scheduler import UnicoreLRScheduler, register_lr_scheduler
@register_lr_scheduler("pass... |
c06c66ae0d7f17db4c609986b6542c6987a261af4a3890938f4cdbfcf7c60875 | Python | 1,297 | 38 | import os
import json
import torch
import pandas as pd
import numpy as np
from tqdm import tqdm
from pathlib import Path
path1 = Path('datasets/Twibot-20/node.json')
with open(path1, 'r') as f:
nodes = json.loads(f.read())
nodes = pd.DataFrame(nodes)
users = nodes[nodes.id.str.contains('^u')]
tweets = ... |
cd578ecaab6950818c4d93c504765c5600543ba206e15d41ade2a7d7d7e70932 | Python | 1,297 | 38 | # -*- coding: utf-8 -*-
"""
Created on Tue Dec 3 23:17:43 2019
@author: Yoshi
"""
import numpy as np
from background_calculator import *
def dfof_converter(raw_data,framerate_information):
# Creates empty numpy array to write data into
cells = raw_data.shape[1]
samples = raw_data.shape[0]
fr... |
262faf6f8b7f312200f13ff620452d585c431d32fb3d8b7870d34a4506fc1f3f | Python | 1,298 | 59 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
# In[12]:
import unitvelo as utv
import anndata
import scvelo as scv
import numpy as np
import os
import argparse
import time
# In[23]:
#scifate2
scifate2_path = '/data/processed/scifate2.h5ad'
# In[24]:
scifate2 = anndata.read_h5ad(scifate2_path)
# Hyperparamet... |
d6936aa4ba7638b8eca234a54c3a7f1c82d25b1d2dc5e63703e78b55d96b2440 | Python | 1,298 | 38 | import os
import json
import torch
import pandas as pd
import numpy as np
from tqdm import tqdm
from pathlib import Path
path1 = Path('datasets/cresci-2017/node.json')
with open(path1, 'r') as f:
nodes = json.loads(f.read())
nodes = pd.DataFrame(nodes)
users = nodes[nodes.id.str.contains('^u')]
tweets ... |
e72e17e499a92ab26c8fd5d0f2ffc260f70307cde9abb6f583944b8de06bc568 | Python | 1,298 | 38 | import copy
from abc import ABC
from typing import Any
class BaseTransform(ABC):
r"""An abstract base class for writing transforms.
Transforms are a general way to modify and customize
:class:`~torch_geometric.data.Data` or
:class:`~torch_geometric.data.HeteroData` objects, either by implicitly
p... |
e80f536e0377ae21f5518d3aa3f85c4c31e4b7f69e25c796f5e9ffa40d5d37ec | Python | 1,298 | 41 | # Copyright (c) DP Technology.
# 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 torch.optim
from . import UnicoreOptimizer, register_optimizer
@register_optimizer("adagrad")
class A... |
0d06c63b5d3e377583dd9187be89243c2a4afb83358ac6d4c98580548a6cdab5 | Python | 1,299 | 43 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
"""Connect to CVAT with a Personal Access Token (PAT) — the recommended way.
Steps:
1. Open an authenticated client.
2. Print the server version.
3. Print who you are authenticated as (a quick sanity check for scripts).
Usage (run ``python au... |
3a3338de290bf651e69ad804913ed32d02aa9ddd075ec3477442d1f9a9c20987 | Python | 1,299 | 40 | """
Rudimentary support for PHAST's tree model file format (a simple format for
storing trees and rate matrices).
"""
from numpy import zeros
class TreeModel:
def __init__(self):
self.alphabet = None
self.radix = 0
self.order = 0
self.subst_mod = None
self.background = Non... |
49a8b43a10afcc4530fd99ea543fcd15740ecadc71154f292d1156fbc2f12274 | Python | 1,299 | 46 | import shlex
import subprocess
from pathlib import Path
from typing import Optional, Required
import click
@click.command()
@click.option("-t1", type=Path, required=True)
@click.option("-o", "output", type=Path, required=True)
@click.option("-l", "license", type=Path, required=True)
@click.option("--threads", type=i... |
4a56ecaed147769aa708fa6b2d5a3a94fe7eaf5d4b6f9a608d78ca604fa372e0 | Python | 1,300 | 39 | def h5tree_view(file):
"""Display HDF5 file structure in tree-like format.
Parameters
----------
:file: h5py.File , opened HDF5 file.
"""
import h5py
assert type(file) == h5py._hl.files.File
def view_h5attributes(obj, depth=0):
atts = obj.attrs
deep = "│ "... |
46a92c74c7f913f2982399757db1d5adbb3f77c0cbe4bc3f81492144ae1e9629 | Python | 1,301 | 29 | from .base_classes import LearningRule, BiasLearningRule
import torch
class DendriticLossBias(BiasLearningRule):
def step(self):
# self.population.bias.data += self.learning_rate * self.population.dendritic_state
self.population.bias.data += self.learning_rate * self.population.plateau
class Den... |
58dffbf97fe4d05c09084843a9e3fbff4786b95162a510c656715075318aed4a | Python | 1,301 | 35 | import torch
from torch import Tensor
import torch.nn as nn
from typing import Union, List
from bism.utils.cropping import crop_to_identical_size
class dice(nn.Module):
def __init__(self):
super(dice, self).__init__()
def forward(self, predicted: torch.Tensor, ground_truth: torch.Tensor,
... |
8bedcadb54224343123bde488a6fd305ba5da76ce6d7e017bafc8d7c9ba18bb5 | Python | 1,301 | 49 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Will compare all input files against the first one for the compatibility
of their spatial attributes.
Spatial attributes are: affine, dimensions, voxel sizes and voxel order.
"""
import argparse
import logging
from scilpy.io.utils import (
add_reference_arg,
... |
de7cc237845693625a93064a373d8fc50602d45c284fbe053e2aa171d3b58eaa | Python | 1,301 | 44 | import json
import csv
from tqdm import tqdm
import time
import os
import pandas as pd
def generate_userful(num):
start = time.time()
dir_ = './datasets/Twibot-22/'
t = json.load(open(dir_ + 'tweet_{}.json'.format(num)))
length = len(t)
print('Read tweet_{} finish:'.format(num), time.time() - star... |
37687cef778f06a9eca56be057e5a6473454c75edc694fbdf223dfeb920f5f64 | Python | 1,302 | 41 | import argparse
import os
import subprocess
from datetime import datetime
parser = argparse.ArgumentParser(description='Run TORUS')
parser.add_argument('qtl_file', help='')
parser.add_argument('annotation_file', help='')
parser.add_argument('prefix', help='Prefix for output file names')
parser.add_argument('-o', '--ou... |
3bcec4ab81791c447c39ad9cbc304bebd5b36da516429eae4743d1b6d0b2d1c6 | Python | 1,302 | 37 | # Copyright (C) 2021-2022 Intel Corporation
# Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import zipfile
from datumaro.components.dataset import Dataset
from cvat.apps.dataset_manager.bindings import (
GetCVATDataExtractor,
detect_dataset,
import_dm_annotations,
)
from cvat.apps.da... |
3f5e80b4a0edaf22b3b2a727522eee899bae455a8e2efe319c597832d6db11e1 | Python | 1,303 | 33 | import argparse
if __name__=='__main__':
parser = argparse.ArgumentParser('Generate all possible peak pairs on the same chromosome '
+ 'and have a distance within [5Kb, 2Mb] from a BED file')
parser.add_argument('input',
help='The input file in BED ... |
4400f6a00af0762f5795f853c24083da6b7f18ab126b7854bdfbb349d2e87c88 | Python | 1,303 | 24 | import os
import ClearMap.Settings as settings
filename = os.path.join(settings.ClearMapPath, 'Test/Data/ImageAnalysis/cfos-substack.tif');
import ClearMap.Visualization.Plot as plt
import ClearMap.IO as io
data = io.readData(filename, z = (0,26));
import ClearMap.ImageProcessing.BackgroundRemoval as bgr
dataBGR = bgr.... |
65ae0fb2fff4c0b90ec291d9ecbb0d9ad2a7b575617036aa2b767ac98965b381 | Python | 1,303 | 41 | # define utility functions
import torch
from math import sqrt
from torch.fft import *
from torch.optim.lr_scheduler import LambdaLR
def ifft2c(k):
return ifftshift(ifft2(fftshift(k))) * sqrt(k.shape[-2]*k.shape[-1])
def fft2c(x):
return fftshift(fft2(ifftshift(x))) / sqrt(x.shape[-2]*x.shape[-1])
... |
98d7fbb38046d76c3ea4e7544c6473310fd5fc58488167bc8de4f04f7a3c6aad | Python | 1,304 | 43 | import numpy as np
import pandas as pd
from joblib import Parallel, delayed
import pickle
from mne import read_source_spaces, spatial_src_adjacency, set_log_file
from mne.stats import spatio_temporal_cluster_1samp_test, permutation_cluster_1samp_test
from scipy.stats.distributions import t
import fire
where = {"I... |
a404cdbad8730f77d3f55dc36eba99ccf44a9dbb077d990b98da00b67d6dccb1 | Python | 1,304 | 49 | """
Computes T1w image in EPI-space from motion-corrected 'nulled' and 'notnulled'
timeseries as acquired with SS-SI VASO.
"""
import numpy as np
import nibabel as nb
from scipy import signal
def computeT1w(nulledFile, notnulledFile, detrend=False):
"""
Takes nulled and notnulled files as input and compu... |
de22a98b7d799660cb66bccb2f9750479b91a542bd293e36bc442ad2e8462ff3 | Python | 1,304 | 31 | import unittest
import base
class Test(base.BaseScriptTest, unittest.TestCase):
command_line = "./scripts/maf_select.py ${features}"
input_features = base.TestFile("""0
0
0
0
... |
e3a0748568db75c4039440f98ed64626f02d39a0d6017b625fddd236e26c4886 | Python | 1,304 | 31 | from PyQt5 import QtGui, QtWidgets
from loader_dialog_UI import Ui_LoadPointDialog
from lasagna.utils import preferences
class LoaderDialog(QtWidgets.QDialog, Ui_LoadPointDialog):
def __init__(self, parent=None, fileFilter=None):
super(LoaderDialog, self).__init__(parent=parent)
# Set up the user... |
eab7b3a9ffb7243306009406b051cce87b0206c6f8dc2c58e68a731d9383b571 | Python | 1,304 | 38 | import os
import json
import torch
import pandas as pd
import numpy as np
from tqdm import tqdm
from pathlib import Path
path1 = Path('datasets/cresci-2015/node.json')
with open(path1, 'r') as f:
nodes = json.loads(f.read())
nodes = pd.DataFrame(nodes)
users = nodes[nodes.id.str.contains('^u')]
tweets ... |
286536f7644a7cccec7ce90adbbf6b0136337f71d9fe397a4a55d1384b21f3b8 | Python | 1,305 | 64 | from dataclasses import dataclass
from scipy.integrate import solve_ivp
import numpy as np
@dataclass
class Params:
# coupling
w_ee: float = 12
w_ei: float = 10
w_ie: float = 15
w_ii: float = 0
# input
P: float = 1.25
Q: float = 0
# decay
tau_e: float = 10 # ms
tau_i: floa... |
da2f591059d3aa8bd6025183a0836e2e896d6e73316c920c9b5393a60f5d2b59 | Python | 1,305 | 33 | import numpy as np
from ..inputs.base import Stimulus
from ..core import ActivationsExtractor
from ..core import TemporalInferencer, Inferencer
from typing import List, Callable, Any, Dict
class ActivationWrapper:
def __init__(
self,
identifier : str,
preprocessing : Callabl... |
175b4e1a0ba4a3db3de8f8b48bab6462d6e9709705d6423c70972dfc7b278ee0 | Python | 1,306 | 53 | import os.path as op
import tempfile
import nibabel as nib
import numpy.testing as npt
import pytest
try:
import onnxruntime as ort
has_onnx = True
except ImportError:
has_onnx = False
import AFQ.data.fetch as afd
from AFQ.nn.brainchop import run_brainchop
from AFQ.nn.multiaxial import run_multiaxial
... |
233448d3d9cdce57ac9f6717c1c9a0bc96aa8c3cea4bdd53242226057b5d115f | Python | 1,306 | 38 | import numpy as np
from skimage.transform import ProjectiveTransform
from typing import Union, List
def fitGeoTrans(src: Union[List[int], np.ndarray],
dst: Union[List[int], np.ndarray],
mode="projective",**kwargs) -> np.ndarray:
"""
This function is the same as matlab fitgeot... |
81838cdf72af7a0a04fb51619ea123bc22e3296d24889aa046ae5a002d7d95b9 | Python | 1,306 | 44 | '''
@author: GM
@edited: CD
'''
import numpy as np
import torch.nn as nn
import torch
from model.modules import ResidualNet3D
class ResNet3D(nn.Module):
'''
Args:
input_dims = [h,w,c] - list or tuple containing dimensions of each input slice
'''
def __init__(self, input_dims,width_f=1):
... |
d20cfca7e11560f377b555ef47f52d7096e1b772ec00ee46ee58b87e02749b47 | Python | 1,306 | 40 | import os
import unittest
from heig import utils
MAIN_DIR = os.getcwd()
class Test_check_compression(unittest.TestCase):
def setUp(self):
self.good_file_compression = {
"test.bgz": "gzip",
"test.gz": "gzip",
"test.bz2": "bz2",
}
self.bad_files = ["te... |
d6c5fc61fb15015e3fef87958eda5fd7f02b50464c96b8ce19ec15eb1cab3727 | Python | 1,306 | 48 | import pytest
from pathlib import Path
@pytest.fixture(scope="module")
def resources_path():
return Path(__file__).parent / "resources"
@pytest.fixture(scope="module")
def tasks_base_path(resources_path):
return resources_path / "tasks"
@pytest.fixture(scope="module")
def results_base_path(resources_path)... |
afafc749e923f55b631c853b24a172f1135954a134e34c1d4b77aa62c31e5266 | Python | 1,307 | 36 | import yaml
import matplotlib.pyplot as plt
import os as os
from datetime import datetime
def main():
listFiles = os.listdir('.')
measurement = {}
meas_value = []
time_value = []
for filename in listFiles:
print(filename)
if not filename.endswith('.yml'):
continue
... |
09ea3dbeee1b972ed8fa7f2ec8a39a30e42217a9e9462b211a0127f7799d61e0 | Python | 1,308 | 44 | import anndata
import os
import sys
import getopt
import pandas as pd
#Usage
def merge_h5ad_usage():
print("""
Usage : merge_h5ad.py -i <filepath>
-o <output>
""",flush=True)
def merge_h5ad_main(argv:[]):
filepath=''
prefix=''
try:
opts , args =getopt.getopt(a... |
6bb934c49761a7fdf61d992c2c4259191798431e25487174cb552ac03d355507 | Python | 1,308 | 43 | from typing import List, Optional
from fastapi import APIRouter
from model.user import UserModel, UserDao
import traceback
router = APIRouter(
prefix="/users",
tags=["users"],
responses={404: {"description": "Not found"}},
)
@router.get("/all", response_model=List[UserModel])
def get_queries():
... |
d6b2c1d8e621f419e0508334a8a0e7ee8e4566940504094add9f8408503f5135 | Python | 1,308 | 36 | #!/usr/bin/python
#########################################
# Author: Yunjiang Qiu <serein927@gmail.com>
# File: restriction_cut.py
# Create Date: 2015-02-27 16:46:15
#########################################
import sys
import argparse
from Bio import SeqIO
import re
def find_site(fasta,seq,outfile):
f = open(ou... |
53c6f8b8a0aaa414248ec57c8c7a05065dadff59e23baa9eb270615f9f0a3828 | Python | 1,309 | 36 | from brainscore_core.supported_data_standards.brainio.assemblies import NeuroidAssembly
from brainscore_vision import stimulus_set_registry, data_registry
from brainscore_core.supported_data_standards.brainio.s3 import (
load_assembly_from_s3,
load_stimulus_set_from_s3,
)
BIBTEX = """"@article{bracci2019ventra... |
c2444519c0e434f26931fad3d513c0a8f341e09fe805f18a604718d3e023d763 | Python | 1,309 | 54 | # torch imports
import torch
import torch.nn as nn
def ABCC_sym(k1d, nintdist):
"""
function that includes permutational invariance for a
molecular system with ABCC symmetrie (such as H2CO).
Permutational invariance is included using fundamental
invariants (https://doi.org/10.1063/1.4961454)
... |
73aedd6db264bb4484e0b02283ec67b5f91657513d2008c6b01114bff99d46f6 | Python | 1,310 | 30 | import subprocess
subs = ['sub-02', 'sub-05', 'sub-06', 'sub-07', 'sub-09', 'sub-10', 'sub-12', 'sub-15', 'sub-16', 'sub-17', 'sub-18']
for sub in subs:
rimFolder = f'/home/sebastian/Desktop/patchFlatten/{sub}_done/upsampled'
outFolder = f'/home/sebastian/Desktop/patchFlatten/{sub}_done/upsampled/registeredF... |
74dd7b26e866c80ed386a1304116f7992218a33a8b6a89cc6359a67db56868d9 | Python | 1,310 | 46 | import sys
try:
from setuptools import setup, Extension
except ImportError:
from distutils.core import setup, Extension
import numpy as np
if sys.platform != 'win32':
compile_args = ['-funroll-loops']
else:
compile_args = []
with open("README.md", "r") as f:
long_desc = f.read()
with open("zebra... |
5500e35518e865236124c569757e76ee851dca21dda8b62ed116ebbfd549a659 | Python | 1,311 | 50 |
class LearningRule(object):
def __init__(self, projection, learning_rate=None):
self.projection = projection
if learning_rate is None:
learning_rate = self.projection.post.network.learning_rate
self.learning_rate = learning_rate
def step(self):
pass
def reinit... |
b2a1296318e5dc0f2832bf78dfc5a1ccb80ac896cfa69e8e7cd056043da3f9cf | Python | 1,312 | 37 | import subprocess
import sys
import yaml
script_calc = 'flatmaps/calc_flatmap_statsdict.py'
script_plot = 'flatmaps/plot_flatmap_enrichments.py'
script_tables = 'flatmaps/write_flatmap_enrichment_tables.py'
scripts = [script_calc,script_plot]#[script_calc]
scripts = [script_plot]
scripts = [script_tables]
pathpath =... |
d40dfa715f9e3f4d49d8534385496c5fbfeeefa2ccf481b2bb4a0c594872bd90 | Python | 1,312 | 46 | # Generated by Django 4.2.17 on 2025-01-13 15:51
import django.db.models.deletion
from django.db import migrations, models
import cvat.apps.engine.models
class Migration(migrations.Migration):
dependencies = [
("engine", "0087_alter_label_type"),
]
operations = [
migrations.AddField(
... |
4cba89579bd93dc744e93fb57175a0b6ebc3cc60f7ac7bb2ae1c8ba4e2e37c3a | Python | 1,313 | 31 | # by Shaoxuan Yuan at 2024/04/22
import os
from PIL import Image
import numpy as np
def convert_to_three_channel_gray(input_folder, output_folder):
"""
将指定文件夹中的所有彩色图片转换为三通道灰白图片。
参数:
input_folder (str): 包含图片的文件夹路径。
output_folder (str): 灰白图片保存的文件夹路径。
"""
# 确保输出文件夹存在... |
4cf58ffb4c49b6ee07fe89a66a7efb73a864458bc90d6a11be6c439b1ee1e634 | Python | 1,313 | 46 | '''Configureation of Generic Object Decoding'''
import os
analysis_name = 'GenericObjectDecoding'
# Data settings
subjects = {'Subject1' : ['data/Subject1.h5'],
'Subject2' : ['data/Subject2.h5'],
'Subject3' : ['data/Subject3.h5'],
'Subject4' : ['data/Subject4.h5'],
'... |
bbc74f57debae75184b595e6f94b031d2fca4fd7bee83cb144fc2f5ec9652596 | Python | 1,313 | 20 | from testsetclass import TestsetClass
class DIPCS10(TestsetClass):
def __init__(self):
self.weak = 1.0
self.molecules = ['h2s_2+', 'c2h4', 'nh3_2+', 'ch2o_2+', 'ph3', 'mg_2+', 'mg', 'ph3_2+', 'ch2o', 'c4h4', 'c2h6_2+', 'n2h2', 'h2s', 'be_2+', 'nh3', 'n2h2_2+', 'c4h4_2+', 'c2h4_2+', 'be', 'c2h6']
... |
c64f362851327df35d706e3eab2f166fcc4dd53f95d23a0f17ac1e29bf6d9a8d | Python | 1,313 | 35 | import os
def get_config(wf, section, config):
"""
Return the absolute path to the desired config file.
The method is going to search for a specified path in the settings.ini.
If no path was specified, a fallback value is used if possible.
Note:
Unlike some other methods, in the case of a re... |
2352f4537f0be685dc0cd367221c3d51d663e8eb467c912053db598ebdd8dffc | Python | 1,314 | 34 | import os
from os.path import join
import glob
#path = '/home/alban/Dropbox/mlab/users/alban/works/InvRend/projects/datasets/TwoTables'
#path = '/home/alban/Dropbox/mlab/users/alban/works/InvRend/projects/datasets/val_geo_eevee'
#path = '/home/alban/Dropbox/mlab/users/shared/jay_illusions/illusion_images'
#path = '/ho... |
24bcadea432a7be241f96cd2a0d0c403bef3ac429cbb7c9f1a8ccd56258b664b | Python | 1,315 | 46 | #!/usr/bin/env python
import click as ck
import numpy as np
import pandas as pd
import gzip
import logging
from utils import NAMESPACES, Ontology, get_goplus_defs
from collections import Counter
import json
import os
import torch as th
logging.basicConfig(level=logging.INFO)
@ck.command()
@ck.option(
'--data-f... |
5cfc505abfcb361040d8a71c7c5af7dfa67fa6aa180f86e14e6bc88253f0f8de | Python | 1,315 | 35 | import pyvisa as visa
import pyvisascope
import multitimer
import time
import yaml
import logging
visa.log_to_screen('INFO')
logger = logging.getLogger('pyvisa')
log2file = logging.FileHandler('experiment.log')
logger.addHandler(log2file)
def main():
# enter here the ID of your device. On windows, VISA you c... |
71803f879bc8774aaa93a36a54649f6d124d5849761fe21ecdbc5ce95136aada | Python | 1,315 | 28 | import functools
import torchvision.models
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_preprocess_images
BIBTEX = """@incollection{NIPS2012_4824,
title = {ImageNet Classification with Deep Convol... |
eca5746189d41227392ab12812318949c716b8d4d69182b297e728b819c87a35 | Python | 1,316 | 47 | """Async helpers shared across ChemGraph CLI and UI."""
from __future__ import annotations
import asyncio
import threading
from typing import Any, Callable
def run_async_callable(fn: Callable[..., Any]) -> Any:
"""Run an async callable and return its result in a sync context.
If no event loop is running, u... |
252705fe839f0ff05ec1b08a5352affd243d4d65fa5c2219b5c0a7cd9e88f944 | Python | 1,318 | 37 | #!/usr/bin/env python
import pandas as pd
import sys
# Uncomment me for actual workflow
chunk_files = sys.argv[1: len(sys.argv)-1]
chunks_to_merge = []
for chunk in chunk_files:
df = pd.read_csv(chunk, sep='\t', index_col=False)
df.rename(columns={'CellBarcode': 'CloneBarcode'}, inplace=True)
df['CellB... |
4e296650fa2d4992604de22babedf0984d1082ff374116f049f2f17d720e5996 | Python | 1,318 | 36 | """
NEMS demo 14: Manifold Projection
Project a waveform into the manifold defined as the penultimate layer of a population CNN
encoding model fit to a large A1 dataset. The resulting projection will provide a
cortical representation of the sound.
Script assumes that interactive matplotlib plotting is enabled.
"""
im... |
6de9a58637f490f28a6d28184afce5ccaa2a16e1d2b864216cee78310007cd75 | Python | 1,319 | 35 | import platform
import django_rq
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError, CommandParser
from rq.worker import Worker
class Command(BaseCommand):
help = "Check worker liveness in specified queues"
def add_arguments(self, parser: CommandParser) -> Non... |
538d2bf52c162d474c8775d719ea5cc3dda043345f55f3d0eeaabe7724db3984 | Python | 1,320 | 43 |
"""
Brings up an alert message to warn the user when something significant has happened.
We can't rely on the user watching the console for messages.
"""
# TODO: maybe neater to just replace with a QMessageBox
# e.g. QMessageBox.information(None, "Hello!", "Something went wrong")
from lasagna import alert_UI
from P... |
66231ed6642d6ed4e52f4a44a13da20390db85868fc4afe316761ec1ba888517 | Python | 1,320 | 36 | #!/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.... |
6be3537deb75455a8966918e565fbeda0d455c0278fb49778e522d3438ae1ddd | Python | 1,320 | 53 | #!/usr/bin/env python
"""
For each interval in `bed1` print the fraction of bases covered by `bed2`.
usage: %prog bed1 bed2 [mask]
"""
import sys
from bx.bitset import BinnedBitSet
from bx.bitset_builders import binned_bitsets_from_file
bed1_fname, bed2_fname = sys.argv[1:3]
bitsets = binned_bitsets_from_file(ope... |
b14d2c59f9f301173f59b21d29bd4d92e03b3f0b45167240b46ae97a3bbca63b | Python | 1,320 | 40 | import os
import numpy as np
import pandas as pd
import scanpy as sc
os.chdir("/data/wuqinhua/phase/covid19/datasets")
samples = ["cov01", "cov02","cov03", "cov04","cov07", "cov08","cov09", "cov10","cov11", "cov12","cov17", "cov18"]
all_adatas = []
for sample in samples:
adata = sc.read_10x_mtx('./pre_data/1_Arun... |
11d14e6e8965fc3d217d2dabbd6fd3b1a8038a0edc02bc6128a1ebe1c31c3f3b | Python | 1,322 | 46 | # Copyright (c) OpenMMLab. All rights reserved.
import warnings
from mmcv.cnn import MODELS as MMCV_MODELS
from mmcv.cnn.bricks.registry import ATTENTION as MMCV_ATTENTION
from mmcv.utils import Registry
MODELS = Registry('models', parent=MMCV_MODELS)
ATTENTION = Registry('attention', parent=MMCV_ATTENTION)
BACKBONE... |
3a220496dbe2455bbf068d6ce7cd436caa092ad6417c9908e82c2b32e7112d7d | Python | 1,322 | 56 | import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
# Halasz_P045_resistance
# Reymond_103
# Reymond_103_Q
case = ['Carotis_2_Mur_rigid','Carotis_2_Mur_rigid']
model = ['carotis2','carotis1']
element = ['A12','A13']
mmHg_to_Pa = 133.3616
start = [0,0]
plt.figure()
data = pd.read_csv("results\\"... |
5bdcf3057d8ad0ff9a019e0b1d301551adc735b2dff7106c2f79d0652327af94 | Python | 1,322 | 28 | import functools
import torchvision.models
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_preprocess_images
BIBTEX = """@incollection{NIPS2012_4824,
title = {ImageNet Classification with Deep Convol... |
75b593998d2d6e9bc1f6985fc234e737c472269f075a1f9cc5c752186e159f05 | Python | 1,322 | 34 | import torch
from batchgeneratorsv2.transforms.base.basic_transform import ImageOnlyTransform
from batchgeneratorsv2.helpers.scalar_type import RandomScalar
class MissingModalityTransform_perImage(ImageOnlyTransform):
def __init__(self, probability: RandomScalar = 0.2):
"""
Custom transform to rand... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.