sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
3bb4f03bae794e73b4e6e74c2ebd54c5bf6aa7fd518043d2f2ec638caeb52c33 | Python | 1,788 | 40 | from brainscore_core.supported_data_standards.brainio.assemblies import BehavioralAssembly
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
# normal distortion:
stimulu... |
7fff784e49f265448c350a7fb8fe6d8e8347cba666a452587d7333b18d558e30 | Python | 1,788 | 56 | # Generated by Django 4.2.26 on 2026-02-09 12:06
from django.conf import settings
from django.db import migrations, models
from django.db.models.functions import Concat, Length, Substr
def path_prefix(apps):
Data = apps.get_model("engine", "Data")
return models.Case(
models.When(
models.... |
bd9a4604ce4cf82440b8ec5f4e92a622b6f94c444d51b0c4ebe4aec0d44ca232 | Python | 1,788 | 53 | # 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
import os, sys
# DOCS_DIR = os.path.abspath(os.path.dirname(__file__))
# ROOT_DIR = os.path.abspath(os.path.join(DOCS... |
05b5e4625b242a6d11239641bcd3a3b56ccf8716152f150b1ae46707e2596037 | Python | 1,790 | 62 | import sys
import time
import getopt
import anndata
from skimage import io as skio
from h5ad_dataframe import h5ad_dataframe
# usage
def mask_h5ad_usage():
print("""
Usage : GEM_toolkit.py maskh5ad -i <input.h5ad> \\
-m <mask.png> \\
-o <output.h5ad> \... |
b58afb7017dca6d9073092e745421d732f16d0387fab1cba116129015642619c | Python | 1,790 | 49 | #utilities for spike properties
import numpy as np
def spike_width(y,x,peaks,height,thresh):
width=[]
halfheight=(np.array(height)/2)+thresh
for i, peakpt in enumerate(peaks):
beg = end = peakpt
while beg > 1 and y[beg - 1] > halfheight[i]:
beg -= 1
while end + 2 < y.siz... |
527c8291b671d983cfd10f9e0108a574e46c5828a7c20952360374fe26708737 | Python | 1,791 | 58 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
from functools import cached_property
import PIL.Image
import cvat_sdk.auto_annotation as cvataa
import cvat_sdk.models as models
from ._torchvision import TorchvisionFunction
class _TorchvisionKeypointDetectionFunction(TorchvisionFunction):
... |
c81a005c5029a18e3573a204847435ab9b226538e64b12ce81ecf18421771b95 | Python | 1,791 | 87 | # -*- coding: utf-8 -*-
# python standard library inputs
import math
# external inputs
import numpy as np
def mask_pattern_2d(nx, ny, a, b, alpha):
"""Mask pattern 2D.
This function computes a mask to occlude parts of the columnar pattern. The
mask has elliptical shape and can be adjusted by its major... |
2e28ceefec00dcfb7716901ce947c4c2213ccb0a613804737b2c7033cfc70a48 | Python | 1,792 | 61 | # -*- coding: utf-8 -*-
"""
Created on Sun Dec 15 18:41:03 2019
@author: Yoshi
"""
from PIL import ImageDraw
def cell_drawer(canvas,cell_location,scale,radius,outline,fill,width=5):
# Prepares for drawing on image
draw = ImageDraw.Draw(canvas)
# Rectangle ROIs
if cell_location[0] == "rect... |
14a615096524264cb779403e05317dca7a0a7119cf5da16350787bd13362726a | Python | 1,793 | 54 | import os
import os.path as osp
import torch
import numpy as np
import scipy
import pandas as pd
import argparse
import os
import torch_geometric.transforms as T
parser = argparse.ArgumentParser(description='display graph features and summary.')
#parser.add_argument('-d','--devices', help='Specify CUDA_VISIBLE_DEVICES... |
5606d1554775e0c8f1d5dee14e15ab95550914ddde0db9b0bf46ae48b182c3d4 | Python | 1,794 | 49 | """Tests for dependency-light CLI helpers: new_config and the fetch checksum."""
import hashlib
import os
import tempfile
import yaml
from click.testing import CliRunner
from surface_morphometrics import cli
from surface_morphometrics import fetch_example
def test_new_config_writes_valid_template():
runner = Cl... |
9ead82c6b66e0bb73133a9e3e7634562f80384f8c0609388a70011394754fe4e | Python | 1,794 | 68 | from langchain_core.tools import tool
import math
import numexpr
from langchain_core.tools import Tool
from langchain_experimental.utilities import PythonREPL
@tool
def calculator(expression: str) -> str:
"""Evaluate mathematical expressions safely.
This function provides a safe way to evaluate mathematical ... |
4317896dce224aac77b3b07033601e9a04a7196b20c6d443672779565d04997a | Python | 1,795 | 46 | import scanpy as sc
import pandas as pd
import anndata as ad
import numpy as np
import logging
adata = sc.read_10x_h5("/data/wuqinhua/phase/CRC/CRC_Cell_raw.h5")
logging.info("read_over")
ct = pd.read_csv('/data/wuqinhua/phase/CRC/GSE178341_crc10x_full_c295v4_submit_cluster.csv',index_col=0)
mt = pd.read_csv('/data/w... |
afbe1f10798892e0e680dc07806a493f8eeafa226f36f1a7a9819c73f2989a1b | Python | 1,795 | 53 | from pydantic import BaseModel, Field
class EMTCalc(BaseModel):
"""Effective Medium Theory (EMT) calculator configuration.
This class defines the configuration parameters for the EMT calculator,
which is a simple empirical potential for metals. It provides a fast
approximation for metallic systems.
... |
5687b19234664aa15336e6389fe667ff02ff95b751c066b08a77be7423b5e26f | Python | 1,797 | 45 | import logging
import os
import click
from project.utils.dips_plus_utils import collect_dataset_statistics, DEFAULT_DATASET_STATISTICS
# -------------------------------------------------------------------------------------------------------------------------------------
# Following code curated for DeepInteract (htt... |
856780fece4489ffef914d8d740d1aa6cfd78564df131dcb5e9c848848151035 | Python | 1,797 | 62 | import numpy as np
import pickle
import fire
from matplotlib.colors import LinearSegmentedColormap
import scipy
based = "../../bids_data/derivatives"
basemsm = f"{based}/msm/sub-average/meg/sub-average_task-POGS_"
def make_movie(stc, name):
brain = stc.plot(
hemi="split",
views=["lateral",... |
8b362317c8e58cb4c173a38d3510aa7749b1727fb56cd68ba2454cfd911bbfbb | Python | 1,797 | 44 | import torch
class Logger(object):
def __init__(self, runs, info=None):
self.info = info
self.results = [[] for _ in range(runs)]
def add_result(self, run, result):
assert len(result) == 3
assert run >= 0 and run < len(self.results)
self.results[run].append(result)
... |
6a788a1017f48bfb0e71a78b5a8a32aca93f27e3be690964529ab9778798a678 | Python | 1,798 | 50 | """
Iter-3 candidate B — SUPERVISED ConvNeXt-Large (non-CLIP control).
Same architecture as iter-1 (convnext_large) but ImageNet-22k supervised pretraining +
in1k fine-tune at 384px, instead of LAION-2B CLIP. This isolates whether CLIP's
language-aligned feature geometry is what tanks the unfitted-RDM benchmarks: if r... |
8609165eeb41c1a29ea9254513948ca744f633d62bca9487dc3e902755fc77b6 | Python | 1,798 | 47 | import torch
def set_seed(seed=42):
"""Set random seed for reproducibility."""
torch.manual_seed(seed)
if torch.cuda.is_available():
torch.cuda.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
def get_chain_organism(pdb_id, chain_id):
"""
Use RCSB PDB API to get the organ... |
91aaa70f5be29cc126dbd1e80218113239d62ddb86e8b709e5a2b2970ac477b4 | Python | 1,799 | 51 | """
CalculateBalancedAccuracy
using HEC_Result.mat, get balanced accuracy.
HEC Result has the true and prediction values for HE/HW classifier and A/E Classifier.
"""
import numpy as np
from scipy.io import loadmat
from sklearn.metrics import balanced_accuracy_score
from pathlib import Path
# HEC_Result.mat Path
dataPa... |
956605fd170f72756a4940e1556c59357f28dc63115113e031d4356e313c641b | Python | 1,800 | 52 | import pandas as pd
uid_req = ["transcript-per-unit", "filterftr-per-unit", "filterpoly-per-unit", "segment-10x-per-unit", "segment-ficture-per-unit"]
rid_req = ["align-per-run", "sge-per-run", "histology-per-run"] + uid_req
seq2id_req = ["sbcd-per-chip", "smatch-per-chip"] + rid_req
sgevisual_req = ["sge-per-run", "h... |
c5d7b17a853f284e9cd876341bcd4dcb6f93fe24d0ff51ce58b8fb47f59f025b | Python | 1,800 | 47 | """ Real labels evaluator for ImageNet
Paper: `Are we done with ImageNet?` - https://arxiv.org/abs/2006.07159
Based on Numpy example at https://github.com/google-research/reassessed-imagenet
Hacked together by / Copyright 2020 Ross Wightman
"""
import os
import json
import numpy as np
import pkgutil
class RealLabels... |
fc6b743e7000d33f07e23c5e6ec1c61ac1050368fed7e3e2ea3e2a8b11c7a504 | Python | 1,801 | 53 | #!/usr/bin/env python
"""
A very simple git parser. Note that this will only give the
correct answer if you run it in a storm-control directory.
Hazen 02/18
"""
import subprocess
from subprocess import check_output
branch = "master"
version = ""
try:
branch = check_output(["git", "rev-parse", "--abbrev-ref", "HE... |
0e9599da0d5283f3b47952a33d9759c44424d93318e307a300d5bddf30e94a8d | Python | 1,802 | 54 | # Copyright (c) 2026 Rohit Jena. All rights reserved.
#
# This file is part of FireANTs, distributed under the terms of
# the FireANTs License version 1.0. A copy of the license can be found
# in the LICENSE file at the root of this repository.
#
# IMPORTANT: This code is part of FireANTs and its use, reproduction, or... |
22eaf051b65138020808b4ab4a6701687c51e2299483e7e1d7bb3330b2711f71 | Python | 1,802 | 64 | from pathlib import Path
import numpy as np
import nibabel as nib
from dipy.io import read_bvals_bvecs
from dipy.core.gradients import gradient_table
from dipy.reconst.fwdti import FreeWaterTensorModel
from matplotlib import pyplot as plt
print('Loading data...')
cwd = Path.cwd()
parent_dir = cwd.parent
data_dir = pa... |
7e4d7a13916e4ff2f3bba5a1d2837570a1f48817f0b09282087575e0eff2bc4d | Python | 1,802 | 51 | """
Implementation of the simple task
"""
import typing
import logging
import datetime
from ..qt import *
from . import task_context
from .widgets import Form, ListAsTabsWidget
from .util import wait_for, wait_for_hold, TaskResult, TaskContextProtocol, CanvasPainterProtocol
from .. import task_controller_pb2
from ..c... |
a95af529fd6fe078fb7c4dbbe6d483b789e794ce3b2e18282ea86f6201b5bfca | Python | 1,802 | 59 | #!/usr/bin/env python
# coding: utf-8
# In[3]:
import scvelo as scv
import numpy as np
import torch
import matplotlib.pyplot as plt
import pyrovelocity as pv
from pyrovelocity.tasks.data import download_dataset
from pyrovelocity.tasks.preprocess import preprocess_dataset
from pyrovelocity.tasks.train import train_d... |
13e59f8cbd3f4b99330cbbe498943f7deff1ab7d866978bc7aa0566dbb7bb8f0 | Python | 1,804 | 55 | import pytest
from torch.utils.data import WeightedRandomSampler
from eir.data_load.data_utils import get_finite_train_sampler
@pytest.mark.parametrize("create_test_data", [{"task_type": "multi"}], indirect=True)
@pytest.mark.parametrize(
"create_test_config_init_base",
[
# Case 1: Linear
{
... |
4f132e7f2187e31f5cdc15d93f81af006e7b1b36277109de8971fd19323a01b0 | Python | 1,804 | 82 | """
H-FNO: Hybrid Fourier Neural Operators for Multi-Physics Sensor Response Prediction
A PyTorch implementation of Hybrid Fourier Neural Operators for fast sensor response
prediction in thermal, acoustic, and flow measurement systems.
Author: Ali Sayghe, Mohammed Mousa, Salem Batiyah, Abdulrahman Husawi
Institution:... |
60dae597348894817deb0b851f5de26c96682def3685d7a22ae9fc973889a8a1 | Python | 1,804 | 48 | # Copyright (c) 2026 Rohit Jena. All rights reserved.
#
# This file is part of FireANTs, distributed under the terms of
# the FireANTs License version 1.0. A copy of the license can be found
# in the LICENSE file at the root of this repository.
#
# IMPORTANT: This code is part of FireANTs and its use, reproduction, or... |
86c56f54ad68fdb1fa845ef5d10b3e69ee883f4260efef95cf5ed39859f775c4 | Python | 1,804 | 44 | import ijson
from tqdm import tqdm
import json
import os
import os.path as osp
if __name__ == '__main__':
for dataset in ['Twibot-22', 'Twibot-20', 'midterm-2018', 'gilani-2017',
'cresci-stock-2018', 'cresci-rtbust-2019', 'cresci-2017',
'cresci-2015', 'botometer-feedback-20... |
8f43a0224decb1590057693d5e9b0f4d27bb352de212c40bf0748091a3d9d11c | Python | 1,804 | 69 | # -*- coding: utf-8 -*-
"""
Created on %(date)s
@author: %(PV)s
"""
from scipy.stats import gaussian_kde
import pandas as pd
import sys
from utils_16_SD import after_deviant,SD_panel_1_combined,correl_matrix, average_oddball,figure4
pd.options.display.max_columns = None
pd.options.display.max_colwidth = None
pd.opt... |
0a803c1a5c31c062603c50a8567290c723f9f3dfabca33512d7f6964f6009fc6 | Python | 1,805 | 61 | #!/usr/bin/env python
# coding: utf-8
# In[3]:
import scvelo as scv
import numpy as np
import torch
import matplotlib.pyplot as plt
import pyrovelocity as pv
from pyrovelocity.tasks.data import download_dataset
from pyrovelocity.tasks.preprocess import preprocess_dataset
from pyrovelocity.tasks.train import train_d... |
113e2cad08888852d9c1e68c2c2f89f314bf7d3c391f267d115c7cadad0e3105 | Python | 1,805 | 80 | # protocol.py
from typing import TypedDict
class GetInfoPayload(TypedDict):
pass
class GetDataPayload(TypedDict):
batch_size: int
class StatusPayload(TypedDict):
pass
class ResetPayload(TypedDict):
pass
class InfoPayload(TypedDict):
dataset_info: dict[str, str | list[int]]
class DataPayl... |
34b7b2a0f7a605c4aa34e10dd3fb495e0148e2084bff4989af562e0d0b032322 | Python | 1,805 | 56 | import json
from monai.data import CacheDataset, DataLoader
from monai.utils import set_determinism
from lightning import Trainer
from lightning.pytorch.loggers import TensorBoardLogger
from lightning.pytorch.callbacks import LearningRateMonitor, ModelCheckpoint
from classifier import NPhaseClassifier
from preprocess... |
62d5281861619bca9c8211b9c6db49c3ddf301dd39b71c303377a692f2f2d97c | Python | 1,805 | 54 | """Get words for example voxels.
Figure 5B.
"""
import numpy as np
import os
import pickle
from utils import (
get_clusters_dicts,
get_stimulus_word_embeddings,
get_vector_top_bottom_word_projections,
load_model_results,
)
model_type = "fasttext"
participant_name = "p01"
voxels_to_plot = [43064, 1049... |
96cb5fd1a90c2d1e529085331c6fa7bebcc836eb0e3ddafed5bc645a53c04b48 | Python | 1,805 | 48 | #!/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... |
a7aff0234662da6f73a05a6c408da435611e67bc48296ec4f32ab98da71f6075 | Python | 1,805 | 66 | #!/usr/bin/env python
import os
import sys
sys.path.append('.')
import click as ck
import numpy as np
import pandas as pd
import gzip
import logging
import torch as th
#DGL imports
import dgl
@ck.command()
@ck.option(
'--string-db-actions-file', '-sdb', default='data/protein.actions.v11.0.txt.gz'),
help='S... |
e5d83b4ab8a487b64891380a28e5ad68271dc19d450a07f6b197d340d9221bea | Python | 1,805 | 23 | from testsetclass import TestsetClass
class PX13(TestsetClass):
def __init__(self):
self.weak = 1.0
self.molecules = ['h2o', 'nh3_2_ts', 'nh3_3_ts', 'h2o_6', 'hf_5_ts', 'h2o_6_ts', 'h2o_2_ts', 'h2o_3_ts', 'hf_3', 'hf_4', 'hf_5', 'hf_2', 'hf_4_ts', 'hf_3_ts', 'h2o_4_ts', 'hf_6_ts', 'h2o_5_ts', 'hf'... |
07a9712144cdcab2a98c3b9b638fd4dbe5112dfb6eaf880a701302c538fc0abb | Python | 1,806 | 49 | import torch
class Logger(object):
def __init__(self, runs, info=None):
self.info = info
self.results = [[] for _ in range(runs)]
def add_result(self, run, result):
assert len(result) == 3
assert run >= 0 and run < len(self.results)
self.results[run].append(result)
... |
be7f07108299f4708f65adf38321429a1ef12d7396538089f9432fedc4255538 | Python | 1,806 | 58 | """Test channel-to-coordinate layout parity with MATLAB.
Run from the repo root::
uv run python python/test_pipeline_channel_layout.py
Diffs ``meanap.pipeline.channel_layout.get_coords_from_layout()`` against
``python/test_fixtures/channel_layout_reference.npz`` (generated by calling
MATLAB's ``getCoordsFromLayo... |
dd7d94f4fd5370c4aaf919d41f3e6616b77290f9add3113781a8884a7b3268c8 | Python | 1,806 | 58 | #!/usr/bin/env python
# coding: utf-8
# In[3]:
import scvelo as scv
import numpy as np
import torch
import matplotlib.pyplot as plt
import pyrovelocity as pv
from pyrovelocity.tasks.data import download_dataset
from pyrovelocity.tasks.preprocess import preprocess_dataset
from pyrovelocity.tasks.train import train_d... |
e98dd53bea76e5a607fc54303253be85013bd43811b189c69ab2a48852a1f67e | Python | 1,806 | 66 | # -*- coding: utf-8 -*-
"""
Upsample vaso outliers
Since the corrected vaso time series is regridded to a new TR, outlier lists
e.g. to censor single volumes based on the realignment procedure, are
transformed to the corresponding timepoints in the resampled timeseries.
"""
# python standard library inputs
import ... |
c290ae245e324881dcee59a4c7ebcbbdd8aaf9c267e1c990cea7220b615828f0 | Python | 1,807 | 64 | from random import shuffle
import cv2
import io
import imageio
import numpy as np
import datajoint as dj
from stimulus import stimulus
schema = dj.schema('pipeline_movies', locals())
@schema
class QualityLabel(dj.Lookup):
definition = """
label : char(4)
---
numeric_label : tinyint
"""
... |
14750efef135d22656db21cd8303dc19aa5c3eb330b148d0b172c7c9cee422a9 | Python | 1,809 | 57 | """Search Experiment Runner."""
import os
import csv
import numpy as np
from analogainas.search_spaces.config_space import ConfigSpace
from analogainas.search_spaces.resnet_macro_architecture import Network
"""Wrapper class to launch NAS search."""
class Worker():
def __init__(self,
cs: ConfigSp... |
3ace7371749945b48097b6e62efa17b57df3600805532c60fe1a5762bbdbe5e7 | Python | 1,809 | 44 | from tests.common import *
class Test_MAE_Pipeline:
def test_pipeline_no_run(self,demo_dir):
LOGGER.info("run monoallelicExpression pipeline with \'run: false\'")
# change the third instance of "run: true" to "run: false" to turn off the MAE module
# run the MAE module using this config_M... |
2da54647b925471a59ec15e6acd43ee885af9fa45001a61c76027bf442a406b6 | Python | 1,810 | 65 | #! /usr/bin/env python
# Copyright 2014 Numenta Inc.
#
# Copyright may exist in Contributors' modifications
# and/or contributions to the work.
#
# Use of this source code is governed by the MIT
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT.
import argparse
import os
import... |
407e5fc2b36a23145eb0f2f58d9ed2703d1702ef43a7269e0cae00278ef64558 | Python | 1,810 | 52 | import os
import numpy as np
import pandas as pd
import sklearn.metrics
import argparse
parser = argparse.ArgumentParser(description='')
parser.add_argument('--output_path', type=str, help='')
parser.add_argument('--answer_path', type=str, help='')
parser.add_argument('--task', type=str, default="binary", help='de... |
bf315885011810db1ae292bb4903700495b5c036d927d28baeebd2539a651efc | Python | 1,810 | 68 | from dataclasses import dataclass
from pathlib import Path
import numpy as np
from eir.data_load.label_setup import get_file_path_iterator
@dataclass
class DataDimensions:
channels: int
height: int
width: int
extra_dims: tuple[int, ...] = ()
original_shape: tuple[int, ...] | None = None
def... |
c330b69005e72838044ba43931c7d6121933e59248e50c357b51ed3d57e750fd | Python | 1,810 | 45 | from setuptools import setup
from os.path import join, dirname, abspath
def read_utf8(*args):
with open(join(*args), encoding="utf-8") as f:
return f.read()
directory, m = dirname(abspath(__file__)), {}
exec(read_utf8(directory, 'celldetection', '__meta__.py'), m)
requirements = read_utf8(directory, 're... |
49f14a56105966397417e9079191d95f75d1613fc43250753d0775fda8c795b4 | Python | 1,811 | 42 | """
PyInstaller hook for pyFAI — full collect.
Why "collect everything":
pyFAI ships:
* Qt .ui descriptors loaded at runtime via pkg_resources
(``pyFAI/resources/gui/*.ui``)
* Calibrant data tables (``.D``, ``.json``)
* OpenCL kernels (``.cl``)
* Icons (``.png``, ``.svg``... |
97a9f530572e1148facccbc1f14e75f9fc1a3e39cd0a4519a007647c56167c54 | Python | 1,811 | 38 | import pytest
from brainscore_vision.benchmarks.majajhong2015.benchmark import load_assembly
from brainscore_vision import load_dataset
from brainscore_vision.benchmark_helpers import check_standard_format
@pytest.mark.private_access
class TestAssembly:
def test_majajhong2015_V4(self):
assembly = load_as... |
c108a738d0f084d0ac7046e0412f2f9b1534ab205273cf36c5e18f9cc99d58e9 | Python | 1,811 | 28 | from testsetclass import TestsetClass
class PCONF21(TestsetClass):
def __init__(self):
self.weak = 1.0
self.molecules = ['GLY_aR', 'GLY_aL', '470', 'SER_ab', '114', 'SER_aR', '99', 'SER_aL', '366', '412', '300', '215', '357', 'GLY_b', 'SER_b', 'GLY_ab', 'GLY_pII', '224', '444', '691', 'SER_pII']
... |
5bf7cff0fd31c5c6646b45dfe4b54ea27d55405e36e38f6af8cfa5ac26cc9d41 | Python | 1,812 | 59 |
from pathlib import Path
from typing import List
import torch
from torch_geometric.data import Dataset, Data
import os, json
__all__ = ['AssignmentDataset', 'InMemoryAssignmentDataset']
def normalize(x: torch.Tensor, eps=1e-6) -> torch.Tensor:
"""Standardize data such that it has zero mean and unit variance"""
ret... |
87e6060df7fe20df1d17419157b2a855058048e7de66b3e31e7a4025cce83139 | Python | 1,812 | 47 | class HierarchicalContrastiveLoss(nn.Module):
def __init__(self, alpha=0.7):
super().__init__()
self.alpha = alpha # 跨层对比权重
def forward(self, projections, labels):
z1, z2, z3 = projections
batch_size = z1.size(0)
# 生成标签掩码 (同一类为正样本)
lab... |
52730357583c43f6eae1d914a140a2bb65301424298cd503ccd17481d5b29c4d | Python | 1,813 | 57 | #!/usr/bin/env python
# coding: utf-8
# In[3]:
import scvelo as scv
import numpy as np
import torch
import matplotlib.pyplot as plt
import pyrovelocity as pv
from pyrovelocity.tasks.data import download_dataset
from pyrovelocity.tasks.preprocess import preprocess_dataset
from pyrovelocity.tasks.train import train_d... |
6046c92c4bd12ccc7f59a47a2647acfac1c66af9647fe6f842795de550fa2e0d | Python | 1,813 | 72 | # Copyright 2014-2015 Numenta Inc.
#
# Copyright may exist in Contributors' modifications
# and/or contributions to the work.
#
# Use of this source code is governed by the MIT
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT.
import os
from setuptools import setup, find_pack... |
953475f59cae1f43edf854897f8682c7d0a69d188b16c8aae6eeffbb2a0e8c20 | Python | 1,813 | 57 | from typing import Literal
from rscvp.util.cli.cli_rastermap import RasterMapOptions
from rscvp.util.cli.cli_suite2p import Suite2pOptions
from argclz import AbstractParser, as_argument, argument
from argclz.dispatch import Dispatch, dispatch
class LaunchRasterMapGUIOptions(AbstractParser, RasterMapOptions, Suite2p... |
9ab016871e02bc976c608a7005c0a31481573855ccfb1f2667a46ccb5641d4e7 | Python | 1,813 | 51 | import numpy as np
import numpy.testing as npt
import torch
from brainways.transforms.depth_registration import (
DepthRegistration,
DepthRegistrationParams,
)
def test_depth_registration_transform_points():
params = DepthRegistrationParams(td=-1, rx=0, ry=0)
transform = DepthRegistration(params, vol... |
9dd6b0c5d099d9fe0d81e0268454ea1b3cf5e825148fa53375c1178c125432e0 | Python | 1,813 | 65 | # coding=utf-8
"""
Tests for deepreg/dataset/loader/util.py in pytest style
"""
from test.unit.util import is_equal_np
import numpy as np
import pytest
import deepreg.dataset.loader.util as util
class TestNormalizeArray:
@pytest.mark.parametrize(
"arr,expected",
[
[np.array([0, 1, ... |
122217afebc848e3d5e1bbd583b53d9cf757e23427028c75005ca50c8b3675f3 | Python | 1,814 | 59 | import os
import numpy as np
import tifffile as tiff
import skimage.io as skio
# Registry for supported formats
FORMAT_REGISTRY = {}
def register_loader(*formats):
"""Decorator to register a new format loader."""
def decorator(func):
for fmt in formats:
FORMAT_REGISTRY[fmt.lower()] = func
... |
977173cfce9f9c493a3e594a10a6fa96b53a8c6037e782fd5f18406c674349c9 | Python | 1,814 | 62 | # -*- coding: utf-8 -*-
"""
Check rivalry switch data
From the condition logfile of the binocular rivalry paradigm, the variable
SwitchData is read and analyzed. The mean and standard deviation of green and
red periods are estimated. The relative amount of piecemeal events is
calculated. This is just a quick overview ... |
d45f963f5ca133b6c313a83af1a2a95a5c846de3c8d50f039b28fff648c642d8 | Python | 1,815 | 57 | from unittest.mock import patch
import pytest
from pyment.models.utils.ensure_weights import IDENTIFIERS, ensure_weights
def test_returns_identifier_when_local_file_exists(tmp_path):
path = str(tmp_path / 'weights.h5')
(tmp_path / 'weights.h5').touch()
result = ensure_weights(path)
assert result =... |
5754089932f236479193d17557388a08a1e4cdb71e3825493ae4fd11008d9768 | Python | 1,816 | 55 | import os
import numpy as np
import pandas as pd
import scanpy as sc
import anndata as ad
from anndata import AnnData
os.chdir("/data/wuqinhua/phase/covid19/datasets")
folder_path = './pre_data/4_Combes_2021/data'
samples = [dir_name for dir_name in os.listdir(folder_path) if os.path.isdir(os.path.join(folder_path, ... |
3a4d6af267a972116a521dad6a8187ecf11ce43a669a81aefda2359922842fa3 | Python | 1,817 | 46 | import socket
import numpy as np
import h5py
# Path to your MATLAB v7.3 .mat file
mat_file = r"C:\Users\MysticSocialist\Documents\GitHub\CLOOSE_MS\Generate_images\WelcomeMsg.mat"
# Load the .mat file using h5py (MATLAB v7.3 files are HDF5-based)
with h5py.File(mat_file, 'r') as f:
# Adjust the key if necessary. H... |
8616dbdabbf38a7b0744ed1deea96264e9df4df908682e418ac286e3c126797b | Python | 1,817 | 49 | from typing import Literal, Final
import polars as pl
from argclz import as_argument
from neuralib.plot import plot_figure
from neuralib.util.verbose import publish_annotation
from rscvp.statistic.core import StatPipeline
from rscvp.util.cli.cli_statistic import StatisticOptions
from rscvp.util.database import DB_TYP... |
ba1b32bf728a9cc5e1005e1139db88d923c26512f0b0a6887aa9c3cf7bb3850e | Python | 1,817 | 54 | #!/usr/bin/env python3
"""
EDF File Property Inspection
Inspects a subset of EDF files to report sampling rates, channel counts,
duration, and estimated sample counts after resampling.
Authors: Evans Nyanney, Parthasarathy D Thirumala, Shyam Visweswaran, Zhaohui Geng
Year: 2025
License: MIT
"""
import os
import glob... |
01678c88258a3b71a14a466c7fe9d6967fe7237018437a32a45786d428e511d6 | Python | 1,818 | 45 | import logging
import os
import click
from project.utils.dips_plus_utils import log_dataset_statistics, DEFAULT_DATASET_STATISTICS
# -------------------------------------------------------------------------------------------------------------------------------------
# Following code curated for DeepInteract (https:/... |
ff4c0b42e2b0e925c74ae0d3a95f8207caf340873df01faa21a051dd0903d76f | Python | 1,818 | 58 | # -*- coding: utf-8 -*-
"""
Created on Tue Dec 3 12:06:03 2019
@author: Yoshi
"""
import numpy as np
from read_roi import read_roi_zip
def roi_zip_reader(flag,roi_zip):
# Reads ROI data from file
rois = read_roi_zip(roi_zip)
# Empty list to store locations and flags
locations = []
fl... |
7134e087ec471ba3b5a888ce71c8cf9e14ad379a12ab6bb09d7fa0bf872ba8b8 | Python | 1,819 | 62 | import nibabel as nib
import numpy as np
import pytest
from pyment.data.utils import ensure_fastsurfer_crop_exists
@pytest.fixture
def mri_folder(tmp_path):
(tmp_path / 'mri').mkdir()
return tmp_path
@pytest.fixture
def mri_folder_with_files(mri_folder):
data = np.ones((10, 10, 10), dtype=np.float32)
... |
90c96e13d5db5cc5a49d6d9c69a03f5611146a48724825b214e7fce30ca78053 | Python | 1,819 | 72 | # %%
# %%
# imports
import os
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
from fractions import Fraction
import ffmpeg
import pandas as pd
from tqdm import tqdm
# %%
# Argle parser
parser = ArgumentParser(
prog='get_video_metadata',
description='Use ffprobe to extract metadata for a se... |
dab79337c42a8ab7ffca1d05efd716082324072445fa6ca4ad15996a43481688 | Python | 1,819 | 53 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
from allauth.account.adapter import get_adapter
from allauth.account.forms import default_token_generator
from allauth.account.utils import user_pk_to_url_str
from dj_rest_auth.forms import AllAuthPasswordResetForm
from django.contrib.auth import get... |
e0700fab3d2765a11832e22042fbd92c5416b6df83bb6f536366ea857be59438 | Python | 1,819 | 62 | # Generated by Django 4.2.15 on 2024-09-25 13:52
from datetime import datetime
from django.db import migrations, models
def _get_0083_move_to_segment_chunks_migration_date(apps, schema_editor) -> datetime:
with schema_editor.connection.cursor() as cursor:
cursor.execute(
"""\
SEL... |
04bb9eb7eeb5079d55a685984a062f0715d76a3d8948f9f1c05a8230b704ded2 | Python | 1,820 | 54 | # Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved
import logging
import os
LOG_LEVELS = {
"DEBUG": logging.DEBUG,
"INFO": logging.INFO,
"WARNING": logging.WARNING,
"ERROR": logging.ERROR,
"CRITICAL": logging.CRITICAL,
}
class ColoredFormatter(logging.Formatter):
"""A co... |
cc1a4a1738732320fe347f5200213b8b2bfade20c4bd6560910d05e9ce7a5ec0 | Python | 1,821 | 53 |
from matplotlib import gridspec
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
from pathlib import Path
cur_path = Path.cwd() / "data" / "bar_3_fold_para34567.txt"
with open(cur_path) as f:
lines = [line for line in f]
num_each_row = len(lines[0].split())
data_set = np.zeros((len(lines), nu... |
e1280d40e6e329dbe8287ca797561f1b32873000f2736b86324663d3dc9e11d0 | Python | 1,821 | 57 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import numpy as np
import PIL.Image
import PIL.ImageDraw
from cvat_sdk import models
from cvat_sdk.masks import decode_mask
def shape_bbox(shape: models.LabeledShape) -> tuple[float, float, float, float]:
"""
Return the unrotated bounding ... |
f32185d7ffccaf72378d740d04df29c35fcfc8cb77382137ae5321a8c9bc7e9b | Python | 1,821 | 54 | import os
import glob
from .session import BIDSSession
from .subject import BIDSSubject
class BIDSUtils:
@staticmethod
def list_sessions(bids_root, subject_label):
"""
List all sessions for a given subject in a BIDS dataset.
Parameters:
bids_root (str): The root directory of th... |
44c087f854ff42a100fc07ce847b5e336e65a007f78a78827e2741319043f222 | Python | 1,822 | 54 | """Test the fetchers module."""
import os
import unittest
from tempfile import TemporaryDirectory
from yasa import fetchers
SMALL_SAMPLE_FILE = "sub-02_hypno_30s.txt"
ALL_SAMPLE_V1_FILES = [
"ECG_8hrs_200Hz.npz",
"EOGs_REM_256Hz.npz",
"N2_spindles_15sec_200Hz.txt",
"N3_no-spindles_30sec_100Hz.txt",
... |
73867d29e674f44f4ff75ee67e728c4b2fb878b9309adec426c249af0b0e5f8c | Python | 1,822 | 50 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
"""Build a CLI-compatible script that reuses ``cvat-cli``'s auth argument set:
``--server-host`` / ``--server-port`` / ``--auth`` / ``--profile`` / ``--insecure`` / ``--organization``.
This is the go-to pattern when your script should feel like an e... |
7a1eee66e563ff27b3962af744b4c9a3ef35c13e76da2511e7236141bdfc95fd | Python | 1,822 | 60 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import os
def is_debugging_enabled() -> bool:
return os.environ.get("CVAT_DEBUG_ENABLED") == "yes"
if is_debugging_enabled():
import debugpy
class RemoteDebugger:
"""
Support for VS code debugger.
Supports bo... |
9afb2e95c4a5e18c612564b95459da60dd3e75dea03530ac8be8b3a20c7ed089 | Python | 1,822 | 61 | #!/usr/bin/env python
# coding: utf-8
# In[3]:
import scvelo as scv
import numpy as np
import torch
import matplotlib.pyplot as plt
import pyrovelocity as pv
from pyrovelocity.tasks.data import download_dataset
from pyrovelocity.tasks.preprocess import preprocess_dataset
from pyrovelocity.tasks.train import train_d... |
b1d29340edd27d0287bcce963d968c5109afda76190b34655a75699d9ce8c859 | Python | 1,822 | 74 | from collections.abc import Callable
from dataclasses import dataclass
from typing import TYPE_CHECKING, Literal
import torch
from torch import nn
from eir.models.input.array.models_locally_connected import flatten_h_w_fortran
if TYPE_CHECKING:
from eir.setup.input_setup_modules.common import DataDimensions
@d... |
40893ebca678b9f607e3b6e91c81aa63ecc0da5ea9b03584454ac5b17f33a67b | Python | 1,823 | 62 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
class colors:
GREEN = '\033[32;1m'
RED = '\033[31;1m'
ENDC = '\033[0m'
import glob
import sys
import os
import subprocess
import argparse
import time
import compareVTI as vti
import compareSTL as stl
VALGRIND_CMD = 'valgrind --tool=memcheck --leak-check=yes --undef... |
b35e5f75e26ff6c50f30258e60589d291a7b94a1d33e5fc78cbd0a37dcf3d4f4 | Python | 1,823 | 59 | import os
from pyment.utils.download_file import download_file
IDENTIFIERS = {
'multi-2025': 'c18be19f64b4e398c446d871a7e9d35ec8c88f1d',
'multi-2025-no-abcd': '1c8e9bc7c33af1625044fb1a54a03500ecc050c4',
'reg-2025': 'a8baaed43082ebac70427a8bf122ffd7c63b51e2',
}
BASE_URL = 'https://api.github.com/repos/este... |
6675aaded53f1db23e73941d014be8e40431280448fdbc88f19a54d94e8146bd | Python | 1,824 | 56 | import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
df_nodes = pd.read_csv("/home/juli/link_vessap/BALBc-no1_iso3um_stitched_segmentation_bulge_size_3.0/BALBc-no1_iso3um_stitched_segmentation_bulge_size_3.0_nodes_processed.csv",sep=';')
df_atlas = pd.read_csv("/home/juli/link_vessap/BALBc-no1_iso3u... |
90fb5f53edcab92f465089ee6eb929e7edc9f4e9cca895cd9b7539d28164ce5c | Python | 1,824 | 66 | import copy
import pickle
import numpy as np
import pandas as pd
import fire
from joblib import Parallel, delayed
import sys
sys.path.insert(0,'..')
import contrasts
import nilearn
import nilearn.image
from nilearn.interfaces.bids import get_bids_files
import nilearn.masking
def process_roi(roi, mask, data):
l... |
918a4d56e65bf05df9e95433017886cd034c93cb9f7e8264d05e2f786d590a66 | Python | 1,824 | 49 | # -*- coding: utf-8 -*-
from datetime import datetime
from parser import Model
from parser.cmds.cmd import CMD
from parser.utils.corpus import Corpus
from parser.utils.data import TextDataset, batchify
class Evaluate(CMD):
def add_subparser(self, name, parser):
subparser = parser.add_parser(
... |
a7c8adf976468bb4e48b3e00034cbcfbc3c9e2984595a284ae737cc873f2f0b1 | Python | 1,824 | 24 | from testsetclass import TestsetClass
class DARC(TestsetClass):
def __init__(self):
self.weak = 1.0
self.molecules = ['P6', 'P3', 'P10X', 'P4', 'P5', 'butadiene', 'P8X', 'P8', 'chdiene', 'ethine', 'P2', 'P7', 'maleinNH', 'cpdiene', 'malein', 'P9', 'P1', 'P7X', 'P9X', 'furane', 'ethene', 'P10']
... |
95ab2b0f0466c576487f5f8935f74889d1830f73a1a1f3d857d3fa7cada0e418 | Python | 1,825 | 43 | import functools
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_preprocess_images
from brainscore_vision.model_helpers.check_submission import check_models
from pytorch_pretrained_vit import ViT
import ssl
ssl._create... |
be0141d2ceae519603e67f7779c9f0b9708acab6b031204c5ad8fa5b3ae88600 | Python | 1,825 | 39 | import unittest
import base
class Test(base.BaseScriptTest, unittest.TestCase):
command_line = "./scripts/maf_extract_ranges_indexed.py ./test_data/maf_tests/mm8_chr7_tiny.maf -c -m 5 -p mm8."
input_stdin = base.TestFile(filename="./test_data/maf_tests/dcking_ghp074.bed")
output_stdout = base.TestFile(fi... |
8b0bfdaea59ba0b71589c5e0c6db0ea2bbcf7f7c3bbd5275cf835b4d19bcfd55 | Python | 1,827 | 60 | """ Create a four cube meshes """
import SVMTK as svm
from pathlib import Path
if __name__ == "__main__":
print("Start ",__file__)
surf = svm.Surface()
outdir = Path("results")
outdir.mkdir(exist_ok=True)
# Creating bounding cube
cube1 = svm.Surface()
# Cube corner coordinates and edge l... |
a6e8785230cf9ca313a382d066d62be26c1ca52277834f2c02e2c96f887ebfb1 | Python | 1,827 | 47 | #!/usr/bin/env python3
"""Train and evaluate the non-physiological artifact detector."""
import json
import logging
import os
from artifact_identification.detectors.non_physiological import NonPhysiologicalDetector
def _save_thresholds(detector: NonPhysiologicalDetector, evaluation: dict) -> None:
"""Persist th... |
bdf5c2c2b31552a6b8e91498bc10ad70b41dd2e8f40f7fcc1b0ec16459e12e99 | Python | 1,827 | 60 | #!/usr/bin/env python
# coding: utf-8
# In[3]:
import scvelo as scv
import numpy as np
import torch
import matplotlib.pyplot as plt
import pyrovelocity as pv
from pyrovelocity.tasks.data import download_dataset
from pyrovelocity.tasks.preprocess import preprocess_dataset
from pyrovelocity.tasks.train import train_d... |
8c29751c5f6453cb15845863743da905c86d427ed8cc2b5d5ada14df7994d041 | Python | 1,829 | 50 | import cooler
import pandas as pd
import numpy as np
mcool_ctrl = snakemake.input.cool_ctrl
mcool_aux = snakemake.input.cool_aux
goiloops = snakemake.input.bedpe
otsv = snakemake.output.otsv
neuron_ctrl = cooler.Cooler(f'{mcool_ctrl}::resolutions/15000')
neuron_aux = cooler.Cooler(f'{mcool_aux}::resolutions/15000')
... |
4005f3901845910dc6584b6868ecf693098a3a81dc4dc1133d6a177035ff427b | Python | 1,830 | 59 | import copy
import logging
from termcolor import colored
from tqdm import tqdm
class TQDMLoggingHandler(logging.Handler):
def __init__(self, level=logging.NOTSET):
super().__init__(level)
def emit(self, record):
try:
msg = self.format(record)
tqdm.write(msg)
... |
abd324062da925f0ce42b3c7a3b64eb1334f0dfdf4efd088def0aa316931dd16 | Python | 1,830 | 51 | #!/usr/bin/env python
"""
HAL module for emulating a (IR) laser for the focus lock.
Hazen 04/17
"""
import storm_control.hal4000.halLib.halMessage as halMessage
import storm_control.sc_hardware.baseClasses.amplitudeModule as amplitudeModule
class NoneIRLaserFunctionality(amplitudeModule.AmplitudeFunctionality):
... |
6c586afbbb7dc004a7b84072b1e4db818facc7a198eca2c7e82b965ad35ad62a | Python | 1,831 | 62 | # coding: utf-8
from pathlib import Path
import matplotlib.pyplot as plt
import pandas as pd
import lightgbm as lgb
print("Loading data...")
# load or create your dataset
regression_example_dir = Path(__file__).absolute().parents[1] / "regression"
df_train = pd.read_csv(str(regression_example_dir / "regression.train... |
b36ef50786dc1e4e9ca8165bb87b249b7f3e41c8ba0eafa81274498d712cd721 | Python | 1,831 | 53 | #!/usr/bin/env python
import sys
import argparse
def parse_args():
parser = argparse.ArgumentParser("Group bed by columns.")
parser.add_argument("-i", '--input', help="The input file.")
parser.add_argument('-g', '--grp', type=int, nargs='+', default=[1, 2, 3],
help="The columns use... |
277e4b12d65c6442719fee147ed9697805897abe08e07457a5d99af97e644335 | Python | 1,832 | 58 | import json
from pathlib import Path
import numpy as np
from eir.experiment_io.io_utils import load_dataclass
from eir.experiment_io.output_object_io_modules.output_io_utils import (
load_output_config_from_yaml,
)
from eir.setup.output_setup_modules.array_output_setup import (
ArrayNormalizationStats,
Co... |
4580dae8ca0e380f0914057e521b822bd0b5d5feefce5c3ca4fe0b38e374a8f4 | Python | 1,832 | 54 | import torch
from tqdm import trange
from collections import OrderedDict
from GEASO.model.graph_aug import random_aug
from timeit import default_timer as timer
def train(
model,
inputs,
args,
):
model = model.to(args.device)
optimizer = torch.optim.Adam(model.parameters(), lr=args.lr1, weight_deca... |
8088948b599ddb699590c9fa493f822b4f249f0b121f259be8240072f4fa9e72 | Python | 1,832 | 57 | from typing import Any
import torch
from torch.utils.data._utils.collate import default_collate
from eir.data_load.data_preparation_modules.imputation import (
impute_missing_modalities_wrapper,
)
from eir.data_load.data_utils import Batch
from eir.data_load.label_setup import Labels
from eir.models.model_setup_m... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.