sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
417d74da974a97a964bd76d4bd66c5fe2b1c49a8f803e69ade47afe77e38db9d | Python | 5,529 | 172 | import torch
import numpy as np
import glob
import os
from deepcardio.neuralop_core.transforms import UnitGaussianNormalizer
from data_processing import CustomDataProcessorGINO
from torch_geometric.loader import DataLoader
from torch_geometric.data import Data, Dataset
from timeit import default_timer
from pathlib i... |
be99ca53a2c1b559a9863659ee26352c675fd342a2ae88824cf62ebc373e0540 | Python | 5,529 | 159 | """Unit tests for the pure helper functions in histo_miner.utils.misc."""
import json
import numpy as np
import pytest
from histo_miner.utils.misc import (
NpEncoder,
convert_flatten,
convert_flatten_redundant,
convert_names_to_integers,
convert_names_to_orderedint,
find_closest_sublist,
g... |
38f04875209ab1a43985aa65993e3083c54acb491c71c1e75a162a6859b0dd45 | Python | 5,530 | 144 | from dgd.diffusion.distributions import DistributionNodes
import dgd.utils as utils
import torch
import pytorch_lightning as pl
from torch_geometric.loader import DataLoader
class AbstractDataModule(pl.LightningDataModule):
def __init__(self, cfg):
super().__init__()
self.cfg = cfg
self.da... |
e135c14b9ac54547de6013d9447b0493490bbdf475d37a4b074aa503ec9efee7 | Python | 5,530 | 163 | import mne
import os
import glob
import numpy as np
import pandas as pd
from scipy.io import savemat, loadmat
import matplotlib.pyplot as plt
import pickle
from mne.preprocessing import ICA, corrmap, create_ecg_epochs, create_eog_epochs
from mne_icalabel import label_components
import sys
sys.path.append('../utils')
... |
4cea46eaede983200a90047c5fe21e8774a95a72ca23887579c9026191169115 | Python | 5,531 | 145 | import time
import random
import math
# TwitterAPI 6253282
# TwitterDev 2244994945
needed_segments = ['created_at', 'public_metrics.followers_count',
'public_metrics.following_count',
'public_metrics.tweet_count',
'public_metrics.listed_count',
... |
9c36d51760f337e0fbea96d79f306568020b0bda62c00e1bc3c40208f2c9ca11 | Python | 5,531 | 185 | import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from matplotlib.patches import Rectangle
import json
df = pd.read_csv('data/synthetic/pemfc_polarization.csv')
with open('results/tables/mechanistic_benchmark.json', 'r') as f:
mech_results = json.load(f)
df_80 = df[df['temperature_C'] == 80.... |
09bfb6343d500db829417d36e2b7bb4d6d3aa8af3f4c9d8f4dbdc127db9e87f8 | Python | 5,532 | 167 | """
Generate images for the "Masked losses" How To tutorial.
Run from the project root with the fireants conda env, e.g.:
conda activate fireants
python docs/scripts/generate_masked_loss_images.py
Writes to docs/docs/assets/howto/:
- masked_loss_input.png
- masked_loss_result_masked.png
- masked_loss_re... |
7ef9c284cffbe897a2170893823d6fa6ea561d8fff6a7ca75744b7be7d1017ca | Python | 5,532 | 145 | # -*- coding: utf-8 -*-
import hashlib
import inspect
import logging
import os
import pathlib
import requests
import zipfile
from scilpy import SCILPY_HOME
DVC_URL = "https://scil.usherbrooke.ca/scil_test_data/dvc-store/files/md5"
def download_file_from_google_drive(url, destination):
"""
Download large fi... |
f55fee078682e84ecde6f40c024283b6b9e212bfc55e8d4d9ad6f3ba0cbec0b6 | Python | 5,532 | 161 | from pathlib import Path
from typing import List, Tuple, Union
from natsort import natsorted
import pandas as pd
from napari.utils.notifications import show_info
def construct_path(input_path: Path, *sub_paths: str) -> Path:
"""
Construct a path by joining the base path with sub-paths.
Parameters:
... |
78f2cc619d1b0c84def25373cf1040031dde4633dbba8dcd400907f2251b170d | Python | 5,534 | 106 | #encoding=utf-8
from __future__ import print_function,unicode_literals
import sys
sys.path.append("../")
import jieba
g_mode="default"
def cuttest(test_sent):
global g_mode
result = jieba.tokenize(test_sent,mode=g_mode)
for tk in result:
print("word %s\t\t start: %d \t\t end:%d" % (tk[0],tk[1],tk[... |
dc5df72ff6cf11d7da932a8d46bd6753400b73fcba1b8e8db1cff4f422648611 | Python | 5,534 | 158 | """
Common place for all the different datasets.
"""
import torch
from torch.utils.data import Dataset
from mcmlnet.training.data_loading.preprocessing import (
PreProcessor,
process_2d_3d_data,
set_deepest_layer_to_zero,
)
from mcmlnet.utils.logging import setup_logging
logger = setup_logging(level="inf... |
34e35e14834026d09669ef336d002751a55f470e232bfc5e5dc7c5455294e2f3 | Python | 5,535 | 160 | import sys
import yaml
import os
import numpy as np
pathpath,myrun,ncluststr,cmethod = sys.argv[1:]
signif_levels=np.array([0.05,0.01,0.001])
nshuff = 1000
savegendspath = '%s/%s'%(cmethod,ncluststr)
ncl = int(ncluststr)
with open(pathpath) as yfile: pathdict = yaml.safe_load(yfile)
rundict_path = pathdict['c... |
6ad6eb36a5a6001bbcb97fd63d0fd41599c0a46f41c8668a5f5968d1e821ba27 | Python | 5,535 | 133 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Oct 3 11:00:46 2025
@author: rl05
Plot Supplementary Figure - Bayes Factor time series
"""
import sys
import os
import os.path as op
import pandas as pd
import pickle
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from mat... |
9c94d34f95ea42b00b873616148cf273372518da886ec8e620b1c8a6e5a78455 | Python | 5,535 | 178 | import os
import time
import torch
import random
import numpy as np
import click
import ray
import traceback
from ray import tune
from ray.air import session
from ray.air.config import RunConfig
import EIANN.utils as ut
os.environ['OMP_NUM_THREADS'] = '1'
os.environ['MKL_NUM_THREADS'] = '1'
def train_eiann(config):
... |
0d7c7bd7cc47ee0ea53e7243eba39ca464bd68114d4287706ab08e0887b0dd84 | Python | 5,536 | 148 | """
HMM: Training
=============
This tutorial covers how to train an HMM. We will use MEG data in this tutorial, however, this can easily be substituted with fMRI data.
"""
#%%
# Getting the Data
# ^^^^^^^^^^^^^^^^
# We will use resting-state MEG data that has already been source reconstructed and prepared. This data... |
635d5484608e415bfa5b95cecacd80c23ff1e45ca6868410013463135ed34ecf | Python | 5,537 | 182 | import ast
import networkx as nx
import os
import pandas as pd
import numpy as np
MASK_TOKEN='_mask_'
class OGB_ASTWalker(ast.NodeVisitor):
def __init__(self):
self.node_id = 0
self.stack = []
self.graph = nx.Graph()
self.nodes = {}
def generic_visit(self, node):
node_... |
85153136ed4e1b9fabccc80c5c493125fd02f80a3c2a73a96b9bfadebe3228a2 | Python | 5,537 | 145 | """How much a run says about itself, and the log that decides it.
``Params.verbose_level`` used to be stored and never read: the GUI offered
three levels and every run printed the same thing. This is what makes the
setting mean something.
The levels are **additive**. ``Verbose`` adds to what ``Normal`` prints;
``Debu... |
d43749d8417ba7c236e23dbd817b8e29a7832af0623e79183bbb5cb0bc0e00f8 | Python | 5,537 | 198 | from pathlib import Path
from typing import List, Optional
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import scipy.stats
import seaborn as sns
import pyls
from pyls import PLSResults
def pls_analysis(
results_df_pls: pd.DataFrame,
condition_col: str,
n_perm: int = 1000,
n... |
99f712fdbccbff3108444a517abf0b01d5f0d56bd415826b5e0a8ac367ea9471 | Python | 5,540 | 135 | import math
import torch
from torch.utils.data import Sampler
import torch.distributed as dist
class OrderedDistributedSampler(Sampler):
"""Sampler that restricts data loading to a subset of the dataset.
It is especially useful in conjunction with
:class:`torch.nn.parallel.DistributedDataParallel`. In suc... |
32d5b38c94fdb6fdd93a3531e682c3f647479d4bf2f05b02b1ab2c18f28a49ab | Python | 5,542 | 86 | """ This script investigates the ability of the model to detect rotor blades of a wind turbine when previously trained
with another turbine's data.
The CNN will be trained on data from location X and its performance will be compared on the test data for location X
and location Y. The same will be performed ... |
49ae96c6bdaf2655f821959b6f773baccd17277f564e8e2ee89dc5aa541db653 | Python | 5,542 | 227 | import sys
import gc
import datetime,time
import uuid
from pathlib import Path
import yaml
import stat
class Color:
## foreground
LIGHTPURPLE = '\033[95m'
PURPLE = '\033[35m'
LIGHTCYAN = '\033[96m'
CYAN = '\033[36m'
LIGHTBLUE = '\033[94m'
LIGHTGREEN = '\033[92m'
GREEN = '\033[32m'
LIGHTYE... |
53ec0976f8a92143b0a1b90427c3a8dd55e225d7858ce4a1d04688eb06bdc4b4 | Python | 5,543 | 171 | import numpy as np
import tensorflow as tf
from tensorflow.keras.layers import Layer
from dft import make_exc_density_calc
class DFTLayer(Layer):
"""
Custom Keras layer that computes exchange-correlation (XC) density based on
features and a neural network output using an external 'exc_density_calc' functi... |
096c15630ea4fdd7fb57441b66fcf1c3715be075ca361216f977d3633d73eaf7 | Python | 5,544 | 189 | # -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup ------------------------------------------------------------... |
214e3d8f5a8ec56cab9d465bec909f26925d761e7ae114f409f2daaacf97a7a1 | Python | 5,544 | 154 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Extract matching WordNet IDs between ImageNet classes and THINGS concepts.
This script compares WordNet IDs from two files:
1. /workspace/Deps/CustomFuctions/classes.py - ImageNet classes with WordNet IDs as keys
2. /data/THINGS/things_concepts.tsv - THINGS concepts w... |
2f93d70920618cb994393e229d22a3279cf0cd3dcfe03b4190fe13ecbd41b3f0 | Python | 5,544 | 106 | #encoding=utf-8
from __future__ import print_function,unicode_literals
import sys
sys.path.append("../")
import jieba
g_mode="default"
def cuttest(test_sent):
global g_mode
result = jieba.tokenize(test_sent,mode=g_mode,HMM=False)
for tk in result:
print("word %s\t\t start: %d \t\t end:%d" % (tk[0]... |
4a8cec94d3ddb861b57a277f02efc727a379f44e8c10a5074db066581ce2bee8 | Python | 5,544 | 116 | import numpy as np
from Bio.PDB.PDBParser import PDBParser
from Bio.PDB.Polypeptide import CaPPBuilder
# -------------------------------------------------------------------------------------------------------------------------------------
# Following code curated for DeepInteract (https://github.com/BioinfoMachineLear... |
e3f70e8390e07c3fa97e988d8bd08c942295db57e1a4a2f44f05d92d339a9979 | Python | 5,544 | 71 | import os
import subprocess
import shutil
import nibabel as nib
import numpy as np
import pandas as pd
from nipype.interfaces.base import BaseInterface, BaseInterfaceInputSpec, TraitedSpec, File, Directory, traits, CommandLineInputSpec, File, TraitedSpec, CommandLine, Directory
from nipype.interfaces.utility import Ide... |
3e2034407e5d38a87aae29ba1a2a94b40a49ff525a9829886f92d3bceaf8830a | Python | 5,545 | 201 | import sys
import datajoint as dj
from distutils.version import StrictVersion
from . import experiment, reso, meso, shared
from .exceptions import PipelineException
schema = dj.schema('pipeline_fuse', locals())
@schema
class Pipe(dj.Lookup):
definition = """ # names of fused pipelines
pipe : ... |
b6ae2665329f3a30da00f5ac30177ca2ad0264886f9df93bc9911ddb0b96978a | Python | 5,545 | 116 | import numpy as np
from Bio.PDB.PDBParser import PDBParser
from Bio.PDB.Polypeptide import CaPPBuilder
# -------------------------------------------------------------------------------------------------------------------------------------
# Following code curated for DeepInteract (https://github.com/BioinfoMachineLear... |
32a10e8ca5093add5d2a427e7e831119329831617a73f3cbc447a4f8de3dfb1e | Python | 5,547 | 173 | import re
import subprocess
from collections.abc import Callable, Sequence
from dataclasses import dataclass
from pathlib import Path
from shutil import copy2
from aislib.misc_utils import ensure_path_exists
from pdf2image import convert_from_path
from PIL.Image import Image
from docs.doc_modules.data import get_data... |
7e286d0d1c89f1dbacf725e13061e8767d9594cc82d05618c1b79b1b206aa58a | Python | 5,547 | 212 |
import os
import sys
from pathlib import Path
from typing import Optional, Sequence
import matplotlib
import numpy as np
matplotlib.use("TkAgg") # or "TkAgg" or "inline"
import matplotlib.pyplot as plt
import waven
from waven.pipeline import ( # noqa: E402
create_gabor_library,
load_spikes_and_positions,
... |
281bc10e51304bbbcb2244f3e6997c49c646843b343c6aded7cdd0de4bf2dbe0 | Python | 5,549 | 186 | # 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 datetime
import pandas
import unittest
fr... |
cdeb004a078ca758c2436dadb2b752000de916de79b7427b63069eb24bf8f6e2 | Python | 5,549 | 169 | import sys
import yaml
import os
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
import h5py
pathpath,myrun,ncluststr,cmethod = sys.argv[1:]
#myrun = 'runC00dMI3_brain'
#pathpath = 'PATHS/filepaths_IBL.yml'
#myrun = 'runIBLPasdM3_brain_pj'
'''
pathpath = 'PATHS/filepaths_carlen.yml'
myrun ... |
023d13ea78c1ebf4224dd9a84fb27a3b8c82e0d49a6dd19a6acdcabbcc6297bf | Python | 5,550 | 177 | from pathlib import Path
import flair
import flair.embeddings
import torch
import torch.nn as nn
from typing import List, Union
from flair.datasets import DataLoader
from flair.training_utils import MetricRegression, Result, store_embeddings
from flair.data import Sentence, Label
import logging
log = logging.getLogg... |
aaf73bd8e6531562ebcc262baf964196b2837df9fd8c781832f841a69c390869 | Python | 5,550 | 150 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import unittest
import uuid
from datetime import datetime, timedelta, timezone
from unittest import mock
import django_rq
from django.conf import settings
from django_rq.queues import DjangoRQ
from rq.job import Dependency, Job
from cvat.apps.engin... |
44b33f8f72561a44f1a480904b9c73b87bfd6686e705f5416071b545a07517de | Python | 5,551 | 169 | """
This is ported from Matlab code from the original TDR codebase.
"""
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import copy
def tdrVectorTimeAverage(coef_time, vecpars, plotflag=None):
"""
tdrVectorTimeAverage Define fixed regression vectors by time averaging coefficient... |
1c4c05958288705351d1282a1e9084415174a59426a36cdb0f1ca03bf7b5c3f8 | Python | 5,553 | 200 | #!/usr/bin/python
#
## @file
#
# RS232 interface to a Applied Scientific Instrumentation MS2000 stage.
#
# Hazen 06/14
#
import sys
import time
import storm_control.sc_library.hdebug as hdebug
import storm_control.sc_hardware.serial.RS232 as RS232
## MS2000
#
# Applied Scientific Instrumentation MS2000 RS232 inter... |
b5c5cbef0a7ae907b53a0c91353b5a9504d4227610889a0314a01d4375f35677 | Python | 5,553 | 158 | import numpy as np
from skimage import measure
from monai.transforms import RandomizableTransform, MapTransform
from scipy.ndimage import binary_fill_holes
class CacheStopHereTransfromd(RandomizableTransform, MapTransform):
def __call__(self, data):
return data
class CropByKeyd(MapTransform):
def __... |
d7d2e35823383fb74af96b32dbb30ae1519c4c00e0a17c1bcd3f6dad22525945 | Python | 5,554 | 145 | from __future__ import annotations
import inspect
from collections.abc import Callable
from functools import partial
from typing import Any, Generic, TypeVar
from magicgui.type_map._type_map import TypeMap
from magicgui.widgets import FunctionGui
__all__ = ["MagicFactory", "magic_factory", "magicgui"]
_FGuiVar = Ty... |
2f80c259782f330b12b3f4b5eb11345416b83e99d6af86da3bbe594089bde01c | Python | 5,556 | 111 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
from __future__ import annotations
from ultralytics.engine.results import Results
from ultralytics.models.yolo.detect.predict import DetectionPredictor
from ultralytics.utils import DEFAULT_CFG, ops
class SegmentationPredictor(DetectionPredictor):
... |
7530945ed6972adb26129be527f71f8f08c6febd851e7f28c2ecab835e59614c | Python | 5,558 | 177 | from pathlib import Path
import matplotlib as mpl
import matplotlib.cm as cm
import matplotlib.pyplot as plt
import nibabel.nifti1 as nifti1
import numpy as np
import pandas as pd
import skimage
mpl.rcParams.update({"font.size": 14})
def plotting_oriented(volume, orientation):
if orientation == "sagittal":
... |
79ec7bd793a00f7e1bddc5521021be28340804fb1693a03b826f5555a82cfc42 | Python | 5,558 | 187 | import unittest
import warnings
from unittest.mock import patch
import matplotlib.pyplot as plt
from argclz import AbstractParser
from rscvp.behavioral.main_tactile_batch import TactileBatchOptions
from rscvp.behavioral.main_tactile_summary import TactileSummaryOptions
from rscvp.track.main_lick_score import LickScor... |
169a20d5ae098b9ef2f78c687fad92680d0ea08cdce1516a23f3ce7a137fec06 | Python | 5,560 | 134 | # (C) Copyright 2020 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing... |
73aedfca0b76e4cb0cf64d03d42d61de4fb1e8c1683b22285e94c852e16ef46d | Python | 5,562 | 170 | """Application-owned cache for arrays derived from BrainGlobe atlases."""
from __future__ import annotations
import re
from collections.abc import Callable
from pathlib import Path
from tempfile import NamedTemporaryFile
from typing import Any
import numpy as np
from napari_dmc_brainmap.utils.cache_paths import app... |
430d2b692d4c02a3c0806a77a6228a8f98068b506429ab4956bfc0bb9b5316c7 | Python | 5,563 | 250 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Generate template from 'MB-KCc-STn' files
"""
import os
import glob
import mbflim.utils as ut
import mbflim.parameters as par
import mbflim.image.image_set_processing as setpro
import mbflim.visualization as vis
#%% Parameters
# Hemisphere
SEL_HEMISPHERES = 'both'... |
7f7ba5f46e53062491641ca3f9b3c5205760b25c2de3a14b86d69e5b1faad65c | Python | 5,564 | 142 | import logging
import os
import nibabel as nib
import numpy as np
import pandas as pd
from joblib import Parallel, delayed
from neuromaps import images, parcellate
from tqdm.auto import tqdm
from .utils import set_log
logging.basicConfig(level=logging.INFO)
lgr = logging.getLogger(__name__)
lgr.setLevel(logging.INF... |
1e8aed8315e359e290fb0d2a5d52d48db55eb80f57f195d913b3fdf625ce9c75 | Python | 5,565 | 153 | # Source: https://github.com/neuraloperator/neuraloperator/blob/main/neuralop/layers/padding.py
from typing import List, Union
from torch import nn
from torch.nn import functional as F
from deepcardio.neuralop_core.utils import validate_scaling_factor
class DomainPadding(nn.Module):
"""Applies domain padding s... |
43ca9cbea575bcf4be1c37e66c2051a4405fdefec281b15f61cacffb835ade04 | Python | 5,565 | 164 | import time
import argparse
import torch
from tqdm import tqdm
from torch.optim import Adam
from pathlib import Path
from types import SimpleNamespace
from eval_utils import load_model, lattices_to_params_shape, recommand_step_lr
from pymatgen.core.structure import Structure
from pymatgen.core.lattice import Lattice
f... |
65f06c1a8cb7ceb6531118ae7b73de40e2224ca043452cb4dbdcb9d14056e911 | Python | 5,565 | 193 | # Kai Sandbrink
# 2023-04-27
#
# %% LIBRARY IMPORT
import numpy as np
from utils import get_timestamp
import os
from sklearn.decomposition import PCA
import matplotlib.pyplot as plt
from sklearn.preprocessing import StandardScaler
from scipy.stats import sem
import matplotlib.patches as patches
from matplotlib.patch... |
87c767e01dd9208ff068fc97cf4e6e6ee05da3f832777c3e952da406c067ae98 | Python | 5,567 | 142 | # This file is part of connectome-manipulator.
#
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2024 Blue Brain Project/EPFL
import os
import numpy as np
import pandas as pd
from numpy.testing import assert_array_equal
from bluepysnap import Circuit
import pytest
from utils import setup_tempdir, TEST_DATA_DIR
... |
ee8e0593536e7363eee7b4c1e759db7819744a692779efd714ff58a947f5055c | Python | 5,567 | 170 | # -*- coding: utf-8 -*-
# python standard library inputs
import copy
# external inputs
import numpy as np
from scipy.signal import find_peaks
# local inputs
from ..utils import get_acorr
def analyze_acorr(arr, fovx, fovy, xv, yv, p_min=0.01, p_max=0.5,
nsample=1000):
"""Analyze Autocorrelatio... |
89a560f9a81c058124f4a373da4ca00cd80b1e7a8941444315da349953c945f2 | Python | 5,569 | 163 | import numpy as np
from scipy.io import loadmat
from scipy import sparse
import sys
import time
import glob
import os
import multiprocessing
from itertools import compress
import argparse
def argument_parse():
parser=argparse.ArgumentParser()
parser.add_argument('--chunklist',action='store', dest='chunklist', requi... |
eab03b96ff4aba573b06521addc1446456155a5f4e1cdc3d8521e1045d108300 | Python | 5,569 | 153 | # This file is adapted from:
# https://github.com/txie-93/cgcnn.git
from __future__ import print_function, division
import torch
import torch.nn as nn
import torch
import torch.nn.functional as F
from .layers import ConvLayer
import torch
import os
import os.path as osp
from functools import partial
from math i... |
c46ed2ed140090865dbef6c154d417f5870700d3ec5cb3acedd767f08389e601 | Python | 5,570 | 111 | import torch
import os
import pandas as pd
import copy
from tqdm import tqdm
class Tester:
def __init__(self, model_path, sample_path=None, device='cuda',
noise_level=250, infer_step=200, th=0.5, use_double_model=False, t1_cond_w=0.5, eta=0.5, guide_w=7.5):
self.dataloader = None
... |
ac64e70a4b7e449a130362a8c9c48a0b13955a19502a4fc94a19979293ebeb65 | Python | 5,571 | 159 | import sys
import os
import os.path as osp
import numpy as np
import torch
from torch.utils.data import Dataset
import cv2
import matplotlib.pyplot as plt
import albumentations as A
from PIL import Image
from albumentations.pytorch import ToTensorV2
from torch.utils.data import DataLoader
#from datasets.cvc_clinic impo... |
687cf924e82b5d6e5361dbcfc8e4f3be2d7328c624b6a310af135226718ec507 | Python | 5,572 | 148 |
###############################################################################
#################### Boilerplate ########################
###############################################################################
import pandas as pd
import matplotlib.pyplot as plt
import os
import matplotl... |
c0a65357d908ab287a3390b63645144b5cfb4b054de0ac65de52bba615da8e88 | Python | 5,572 | 135 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
"""Depth estimation validator for YOLO models."""
from __future__ import annotations
from pathlib import Path
from typing import Any
import torch
import torch.distributed as dist
import torch.nn.functional as F
from ultralytics.models.yolo.detect i... |
9b93706d1edc3099cdc4edc4a1372c0d14c0c4c9957c5abf10bc8e46afde19d6 | Python | 5,575 | 157 | import torch
import torch.nn.functional as F
from fairseq.modules.multihead_attention import MultiheadAttention
class MultiheadAttentionDASA(MultiheadAttention):
"""
fairseq 0.12.2 compatible.
dep_bias: FloatTensor [B, T, S] aligned to src_tokens (subword level).
modes:
- mul: logits = logits * ... |
1284475d638405fe561e48ced3dbf973878359e65d132c00fea8221fbf78d69f | Python | 5,580 | 150 | import time
import argparse
from tqdm import tqdm
import torch
import numpy as np
import torch.nn.functional as F
from torch.utils.data import DataLoader
from torch.nn import ModuleList, Linear, BatchNorm1d, Identity
from ogb.utils.url import makedirs
from ogb.lsc import MAG240MDataset, MAG240MEvaluator
from root imp... |
a0d0fc9df4dcd60c1bbdc1c1f312b2f67f12d388c268735e48adb3d743fcf4e7 | Python | 5,580 | 128 | import os
import numpy as np
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt
import pickle
from matplotlib import pyplot as plt
from pcntoolkit.normative import predict, evaluate
from utils.training.nm_utils import load_2d
#externally : colors, y_lim
#externally : compute yhat, s2?
de... |
e070b21aed25c73b312f9bc34a791bb4ef79a1c38f6b7d88b185ae06de3f69d4 | Python | 5,581 | 150 | import numpy as np
from scipy.ndimage import gaussian_filter1d
from argclz import AbstractParser, argument, as_argument
from neuralib.plot import plot_figure
from neuralib.plot.colormap import insert_colorbar
from neuralib.suite2p import normalize_signal, get_neuron_signal, sync_s2p_rigevent
from rscvp.spatial.main_ca... |
e2fc6215de6e00d65f43908b3bdef24ddb2fc0847409215511fdb72d7ea191a0 | Python | 5,582 | 220 | # -*- coding: utf-8 -*-
__author__ = "Felix Niemöller"
__email__ = "usnrb@student.kit.edu"
"""
Maps labels to integers.
Usage example:
from torchaskivit.constants import ASKIVIT_LABELS_V1
"""
## ****************************************************************
## * ASKIVIT V1.4 ... |
8f75105ef2c70427a41a8d215cea1350fa71a1052c61bc919c45f0a4f718c916 | Python | 5,583 | 127 | import scipy.stats
import xarray as xr
from tqdm import tqdm
from brainscore_core.supported_data_standards.brainio.assemblies import walk_coords, DataAssembly
from brainscore_core import Metric, Score
from brainscore_vision.metric_helpers import Defaults as XarrayDefaults
from brainscore_vision.metric_helpers.transfor... |
a5fa1e6f72467d335dd435577804b7a622e824ffaf449d646b66eb88c00f14c8 | Python | 5,584 | 134 | """The Results tab: what it opens, and whether it says so.
**View report** never named the thing it would open. It falls back to the folder
the current settings describe, so in a fresh session pointed at yesterday's
paths it acts on a run nobody mentioned; and for an express run it opens a
bundle in the viewer rather ... |
ed6dc98e6894ce12d1e4209b02bf43d1b440e83778c80d4e53368ca8c7e17a96 | Python | 5,584 | 148 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Script to compute FA/MD/RD/AD for
each Multi-ResolutionDiscrete-Search (MRDS) solution.
It will output the results in 4 different 4D files.
Each 4th dimension will correspond to each tensor in the MRDS solution.
e.g. FA of tensor D_1 will be in index 0 of the 4th dimens... |
8d150955e57bbeec7f0f33d619748424a2be085b470d687f4d0e1dc568bf5282 | Python | 5,585 | 172 | import pandas as pd
import numpy as np
import math
import json
from sklearn.metrics import roc_auc_score as auc
from numpy import histogram_bin_edges as bin
from sklearn.ensemble import RandomForestClassifier
import torch
from tqdm import tqdm
from scipy.stats import entropy
import argparse
from datetime import dateti... |
28a12efa45a220344bd85c66c71035305d306c07de5bbe659eb9a898c6f56537 | Python | 5,586 | 112 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
from __future__ import annotations
from pathlib import Path
import numpy as np
import torch
from ultralytics.utils import LOGGER, NUM_THREADS
from ultralytics.utils.checks import check_requirements
from .base import BaseBackend
class LiteRTBacke... |
37c4d2989a3c0256d98e371a99ed315bf8d9bcc3a2acbe5a870eaabf9623a5bb | Python | 5,586 | 153 | from typing import Callable, List, Union
import torch
from torch import Tensor
from torch_geometric.nn import GCNConv, TopKPooling
from torch_geometric.nn.resolver import activation_resolver
from torch_geometric.typing import OptTensor, PairTensor
from torch_geometric.utils import (
add_self_loops,
remove_sel... |
a5ccb9edc5933d1c0c69429ffde5e28632c925e51f09b95dfb163384cff502be | Python | 5,588 | 225 |
import torch, torch.nn as nn, torch.utils.data as data, torchvision as tv, torch.nn.functional as F
import pytorch_lightning as L
import numpy as np
from torch.utils.data import Dataset, DataLoader
from sklearn.metrics import roc_auc_score
from pytorch_lightning.callbacks import ModelCheckpoint
class EncoderV1... |
f75876699e06db96fbb9105a8ee5a3c927694dfa98d179b37297ab47a2926350 | Python | 5,588 | 142 | import numpy as np
class LineString3D:
""" " Class for operating on 3D paths
Akin to the 2D LineString class in the shapely package (but not nearly as
fully featured).
Parameters
----------
coords : (N, 3) array
3D coordinates that define the path
"""
def __init__(self, coor... |
7110f7242d95da9e4388e03f2cae117891eb575012ddaccd4ddc21e4c80aa0be | Python | 5,589 | 171 | #!/usr/bin/env python
"""
From a set of regions and two sets of intervals inside those regions
compute (for each region separately) the overlap between the two sets
of intervals and the overlap in `nsamples` random coverings of the
regions with intervals having the same lengths. Prints the z-score relative
to the mean... |
903dafc89830cf700c80d2580216a4bb6c042dddf9128da6d49b83f0119ffbe2 | Python | 5,589 | 161 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 29 21:22:22 2016
@author: ajaver
"""
import numpy as np
import tables
from tierpsy.analysis.traj_create.getBlobTrajectories import generateImages
from tierpsy.helper.misc import TimeCounter, print_flush
from tierpsy.helper.params import read_fps
... |
987e5d07d5142985716a2a8afe63b4ae3fec761ca3244664ef63907e5c316d8f | Python | 5,590 | 207 | import json
import numpy as np
import pytest
from napari_dmc_brainmap.registration.sharpy_track.sharpy_track.model.coordinates import (
coordinate_scale_matrix,
display_to_native_point,
homography_to_display_space,
native_to_display_point,
scale_coordinate,
)
NATIVE_SIZE = [1140, 800]
DISPLAY_SI... |
b55c3d4bafdafcdf6f4c49fe550ba934a7a8eeebb64dbe9f5e8784ab48bb37c2 | Python | 5,590 | 89 | import numpy as np
import argparse
import pickle
def parse_args(commandline,do_exit,flag):
#Descriptive variables used in subsequent program to select similar data to average:
parser = argparse.ArgumentParser()
exp=['exper','--exper']
sex=['sex','--sex']
age=['age','--age']
drug=['drug','--drug... |
4311c2f2207a1f51abfa9bc4d6ecd7d429123c7bbf1b8c666966b9e7aba514da | Python | 5,591 | 81 | """Export immutable result views; no models or enrichment tests are run."""
import csv
import hashlib
import json
import math
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
OUT = ROOT / 'explorer/src/data'
ARCHIVE_DOI = '10.5281/zenodo.22849800'
SITE_URL = 'https://psilocybin-research.github.io/ps... |
651ac80f6854477fbfcf964b2ca7657dc8a732ebc821688a9e02dc25e5a14525 | Python | 5,591 | 104 | # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'hbaic1-misc.ui'
#
# Created by: PyQt5 UI code generator 5.7
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjec... |
a38b86ed6ddf4bb67ffeeb28ac4a68c5e81323e98fddf7caf40efc04110f1308 | Python | 5,591 | 159 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Assign a uniform color to one or many surfaces.
The color can be provided as an hexadecimal string or via a JSON dictionary
mapping surface basenames to colors.
Example:
scil_surface_assign_uniform_color surf.vtk --fill_color 0xFF0000 \
--out_surface col... |
4e6efe8add6d2a459aba37ee0bc6e564b67b521f9767d48919aebcab32821b6e | Python | 5,592 | 150 | import os
import yaml
import h5py
import sys
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from scipy.stats import kendalltau,pearsonr
import pandas as pd
pathpath,run1,run2,stag1,stag2,ncluststr1,ncluststr2, cmethod = sys.argv[1:]
stags = [stag1,stag2]
'''
run1 = 'runC00dMP3_brain'
run2... |
7591b4d6a698d13a66a7d58ad25812f60290fa0e0900b1dc34408e4ca77c3fdf | Python | 5,592 | 148 | import click
import torch
from time import time
import EIANN.utils as ut
@click.command()
@click.option('--network-config-file-name', help="YAML file in EIANN/network_config/mnist", required=True)
@click.option("--data-dir", type=click.Path(exists=True, file_okay=False, dir_okay=True), default='../data/mnist')
@click.... |
10ea330dfd7c1514a3e6de77ff7689625f912e3a505fae1eee357884f803db44 | Python | 5,593 | 170 | from pathlib import Path
import numpy as np
from datetime import datetime
from typing import ClassVar, Final, Literal
from argclz import argument, int_tuple_type, str_tuple_type
from neuralib.facemap import read_facemap, FaceMapResult, KeyPoint
from neuralib.util.interp import interp_timestamp
from neuralib.util.util... |
14c8a807c458bb3278aff78d8097d8994b76b880fa17e5a9cdb62bbe6bb2ccce | Python | 5,593 | 224 |
import torch, torch.nn as nn, torch.utils.data as data, torchvision as tv, torch.nn.functional as F
import pytorch_lightning as L
import numpy as np
from torch.utils.data import Dataset, DataLoader
from sklearn.metrics import roc_auc_score
from pytorch_lightning.callbacks import ModelCheckpoint
class EncoderV1... |
35b928a9c77e89ce0fe90e2e0f614419299909473a29c8b6796b81486457f793 | Python | 5,594 | 146 | import numpy as np
from matplotlib import pyplot
from matplotlib import gridspec
from scipy import optimize
import pop_spike_utilities as psu
######## This function calculates averages across experiments
def exp_avg(datas, datatype=None,somethreshold=999e6):
if not datatype:
alldatavalues=datas
#pr... |
5211f3dec1aab12065cb0be2a58c709ad6990f7994fec0f78ce6d2b25a2df3eb | Python | 5,594 | 210 | """Tests for the tqdm wrapper."""
from time import sleep
import pytest
from magicgui import magicgui
tqdm = pytest.importorskip("tqdm", reason="need tqdm installed to test tqdm")
from magicgui.tqdm import tqdm, trange # noqa
def test_tqdm_outside_of_functiongui():
"""Test that we can make a tqdm wrapper with... |
a83995d7698a4218186756cdd790655f755b557e3e6bcbb74cf3ab01308b5569 | Python | 5,594 | 132 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Compute a single Fiber Response Function from a DWI.
A DTI fit is made, and voxels containing a single fiber population are
found using a threshold on the FA.
----------------------------------------------------------------------
Reference:
[1] Tournier et al. NeuroI... |
7b25d3c7d0eda8c4bc36e86842dbbe288d02279eb0d1c69ce0136f3430ad64d0 | Python | 5,595 | 151 | """Small-worldness parity + structural tests (``network_metrics
.small_worldness_rl_wu`` and ``null_models.randmio_und_v2``/
``latmio_und_v2``).
Run from the repo root::
uv run python python/test_pipeline_small_worldness.py
``small_worldness_rl_wu`` is deterministic *given* a real network ``A`` and
two null mode... |
c667c6588473d771fc3b1999f708bb44b465a242d988dfd9d8a391ac5fb7d90b | Python | 5,596 | 142 | # -*- coding: utf-8 -*-
# @Author : LG
import os.path
import requests
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtGui import QValidator
from ISAT.configs import CHECKPOINT_PATH
from ISAT.ui.remote_sam_dialog import Ui_Dialog
class RemoteSamDialog(QtWidgets.QDialog, Ui_Dialog):
def __init__(self, parent, ... |
07c131e22c3781a5993c38ab4c5de898d7361baef4042fe7c6827c1505670500 | Python | 5,598 | 133 | import os
import yaml
import torch
import random
import models
import argparse
import numpy as np
import torch.nn as nn
from utils.utils import *
from scipy.io import loadmat
import matplotlib.pyplot as plt
from torch.amp import autocast
from torch.utils.data import Dataset, DataLoader
from torch.utils.ten... |
d0a64c739beeb9589c4c53251662374aa43e4b5104b8d0a93d525e87d3043e1a | Python | 5,599 | 170 | # -*- coding: utf-8 -*-
"""
Analysis of simulated ocular dominance columns
The purpose of the following script is to simulate ocular dominance columns and
estimate their column width and column spacing.
To do so, the power spectrum and the normalized autocorrelation (NAC) map are
computed and evaluated along differen... |
632f6562d9bd3f0a3d7a9263ba77ff7567aea57e41c359c6968d4612230694b3 | Python | 5,603 | 159 | import os
import logging
import unittest
import pandas as pd
import numpy as np
from pandas.testing import assert_frame_equal
from heig.voxelgwas import (
check_input,
)
MAIN_DIR = os.path.join(os.getcwd(), "test", "test_secondary")
log = logging.getLogger()
log.setLevel(logging.INFO)
class Args:
def __ini... |
74009e558cb385c7e73c273983b36c716431113f342330dfeec0b9a98f8f00c9 | Python | 5,603 | 139 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
from __future__ import annotations
import random
import shutil
from pathlib import Path
from ultralytics.data.utils import IMG_FORMATS, img2label_paths
from ultralytics.utils import DATASETS_DIR, LOGGER, TQDM
def split_classify_dataset(source_dir:... |
29264c8d33ad32e7aaccb0d875b1dd679627a6663fcfc75c6e04fcdb8441ac53 | Python | 5,604 | 182 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
from __future__ import annotations
import itertools
from collections.abc import Callable, Sequence
from typing import NamedTuple, TypeAlias, TypeVar
import numpy as np
from attrs import define
from scipy.optimize import linear_sum_assignment
from ... |
4f825abdfddd34a3d2297af76462cfeab516973e688ecbcc957d6af4bbf64786 | Python | 5,604 | 179 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date: Created on 28 Aug 2023 09:19
# @Author: Yao LI
# @File: clustering.py
import pandas as pd
from sklearn.linear_model import LogisticRegression
import hdbscan
import sys
from pcg_pattern import *
from scipy.ndimage import gaussian_filter1d
import numpy as np
from p... |
90e91d2210397aa32461194b0e42f0b44f97f76de2875909635b6e0183051fd3 | Python | 5,604 | 177 | import random
import numpy as np
from collections import defaultdict
from sklearn.neural_network import MLPRegressor
from analognasbench.data import AnalogNASBench, DriftMeasurement
def architecture_to_feature_vector(arch):
return np.array(list(arch), dtype=float)
def evaluate_architecture(benchmark, arch, metr... |
a9e5b2e6f7d05ffd9ec20d79b7f1e2119a5968141f4e0a124c381d6a3025c8f8 | Python | 5,604 | 187 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import logging
from collections.abc import Iterable, Sequence
from typing import Any, TypeVar
from django.conf import settings
from django.db import DatabaseError, connection
from django.db.models import Manager, Model, QuerySet
from psycopg2 import... |
4fa1c8f44c10a9120da0b214a4537ed48f11857cb8246ce9e4cff2332552b356 | Python | 5,606 | 161 | # This code was adapted from https://github.com/theislab/scanpy/scanpy/conf.py
# This file is therefore licensed under the license of the scanpy project,
# available from https://github.com/theislab/scanpy and copied here at the time of accession.
# Note that multiple changes were made to this file to adapt it to the d... |
a681e5356b458e429822852d1d6fa43d255acd0632029efbdeaa19dd57036d27 | Python | 5,606 | 146 | """
Performs temporal upsampling and BOLD-correction.
Also computes some QA measures.
"""
import subprocess
import glob
import os
import nibabel as nb
import numpy as np
ROOT = '/Users/sebastiandresbach/data/s1Anfunco/Nifti'
TR = 1.9295
# subs = ['sub-15', 'sub-16', 'sub-17', 'sub-18']
subs = ['sub-07', 'sub-09',... |
ef8f85978222fd793a5fe5076d38a86ec28bc1772c89b9aa138a2b73e4a7e696 | Python | 5,606 | 154 | import numpy as np
import torch
import re
import os
from tqdm import tqdm
from torch_geometric.data import InMemoryDataset
from mlcg.utils import download_url
from mlcg.data import AtomicData
class DimersDataset(InMemoryDataset):
"""General base extractor for the Dimers dataset used in LODE https://doi.org/10.1... |
03f81124b73f85a8193bc4c84ad9d2f8f7ebd1a27f35e17e3710581872a84b01 | Python | 5,610 | 157 | import os
import sys
from pathlib import Path
import argparse
import numpy as np
import nibabel as nib
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision.models as models
import torch.optim as optim
from torch.utils import data
## Please specify the directory of the LPCNN code from ... |
70cc399ff4bd3759e9b1686e7d6854f7137d35aa01c0538a10527afd1b646805 | Python | 5,610 | 161 | from collections import namedtuple
import os
import math
import random
from tkinter import W
import pandas as pd
import numpy as np
from tqdm import tqdm
from glob import glob
import torch
import torchaudio
from torchaudio import transforms as T
from .augmentation import augment_raw_audio
__all__ = ['save_image', 'g... |
eb5b8f63d99955a110f94a01ec1d51e0fd1e2a1f82e065f6f17583134af3989c | Python | 5,610 | 198 | """Configuration and utility functions for loading and processing data."""
import os
from typing import Any
import numpy as np
import pandas as pd
import yaml # type: ignore[import-untyped]
from dotenv import load_dotenv
from mcmlnet.utils.logging import setup_logging
load_dotenv()
logger = setup_logging(level="in... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.