sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
c43651a62078cf4139cdf717c73480d16f5847d183f72863f5b9b2dc761c5983 | Python | 3,876 | 132 | #!/usr/bin/env python
"""
RS-232 interface to an ASI tiger controller.
Hazen 05/18
"""
import traceback
import storm_control.sc_hardware.serial.RS232 as RS232
import storm_control.sc_library.hdebug as hdebug
class Tiger(RS232.RS232):
"""
Tiger controller interface class.
"""
def __init__(self, **kwd... |
34fe0bd9f1f15f45e7ce3660bfe28b53d137e697fda1fbc21e917741703306b2 | Python | 3,877 | 92 | #%% set environment
import numpy as np
import matplotlib.pyplot as plt
from os import makedirs
from os.path import join
from tqdm import tqdm
from skimage import transform
import torch
from segment_anything import sam_model_registry, SamPredictor
import glob
import os
import argparse
def show_mask(mask, ax, random_col... |
05324c63ee7e93f3e677c04df047295230bda567482bacf913848e8c96a50b60 | Python | 3,878 | 113 | import os
from copy import deepcopy
import numpy as np
import argparse
import innvestigate.utils as iutils
from keras.models import Model
from keras.preprocessing import image
from keras.utils import to_categorical
import keras
import tensorflow as tf
from numpy import average, dot, linalg
from utils import *
from lrp ... |
cd0dbbcdffe3b7ed3569b36f85a02b0d49ec3ce5a9fe9080d6d3bf13b7ae0441 | Python | 3,878 | 141 | # The ImpedanceFitter is a package to fit impedance spectra to
# equivalent-circuit models using open-source software.
#
# Copyright (C) 2018, 2019 Leonard Thiele, leonard.thiele[AT]uni-rostock.de
# Copyright (C) 2018, 2019, 2020 Julius Zimmermann,
# julius.zimmermann[AT]un... |
80c7334804e72e46fe74baa290ab3677732df6d127fe0c6886d799c040429f60 | Python | 3,879 | 106 | import os
import numpy as np
import pandas as pd
import time as tm
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
import rpy2.robjects as robjects
def run_LDA(DataPath, LabelsPath, CV_RDataPath, OutputDir, GeneOrderPath = "", NumGenes = 0):
'''
run baseline classifier: LDA
... |
893cd889fd56bdb3179cc7613cc7efae455a01b9ccd34f56881fdffc9599aa15 | Python | 3,879 | 98 | import json
import warnings
from itertools import chain
from typing import Callable, List, Optional
import torch
from torch_geometric.data import Data, InMemoryDataset, download_url
from torch_geometric.utils import to_undirected
class WikiCS(InMemoryDataset):
r"""The semi-supervised Wikipedia-based dataset fro... |
230e632b4895217aef7997abdedc67027309c43cfdd62467d808cd8f3ef1b1d1 | Python | 3,881 | 109 | from __future__ import annotations
from typing import TYPE_CHECKING, Any
from magicgui.types import Undefined
if TYPE_CHECKING:
import inspect
from magicgui.application import AppRef
from magicgui.widgets import Widget, protocols
def create_widget(
value: Any = Undefined,
annotation: Any | Non... |
37b2e777b52ce6c08bc71ab94a7058ded6e39cf5935a48f31997e24e0bcee32b | Python | 3,881 | 113 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Jul 31 2018
@author: Vicky
usage: python generateSummaryFiles.py metric_summary
"""
import glob, xlsxwriter, csv, sys, ntpath, os
from shutil import copyfile
metricsPath = 'finalreport/'
summaryPath = 'finalreport/summaries/'
def main(arg1='metric_summ... |
dde4a2417b5e4942d3ae3414974573c6e177563ad8ea2efaebb41e9c0a2006c0 | Python | 3,881 | 101 | import sys
sys.path.append('../semantic_spaces/')
import numpy as np
import pickle
import gzip
import os
import embeddings as emb
from typing import Any, Union
class RTFE:
'''
This is an implementation of the free-energy model detailed in our previous
paper (to be referenced once submitted). Here, the k... |
ef45ff923535af010e95cb03e1708d9181f947311102cf8010642531becd82c1 | Python | 3,882 | 107 | import os
import numpy as np
import pandas as pd
import time as tm
from sklearn.ensemble import RandomForestClassifier
import rpy2.robjects as robjects
def run_RF(DataPath, LabelsPath, CV_RDataPath, OutputDir, GeneOrderPath = "", NumGenes = 0):
'''
run baseline classifier: RF
Wrapper script to... |
0f6ab32034ab0e0471f5b26856fa032303351736c84efdac52d7e5a618c12d3b | Python | 3,883 | 97 | #!/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.... |
5197e3da72b8192d54ffb46e7a1642bf147f0de25ebe744a5f94392700f5414e | Python | 3,884 | 96 | import warnings
warnings.filterwarnings("ignore", message="It is not recommended to directly access")
import torch
import torch.nn as nn
from dataset import BatchMolGraph
from .HGNNEncoder import HGNNEncoder
from .ExplainableCrossAttention import ExplainableCrossAttention
class ExplainableCrossAttentionEncoder(nn.Modu... |
d0ca24b9b07f911de4d377613c9116dda18e6add0bff4fc62fca7e0e2f6f0d6b | Python | 3,884 | 106 | import numpy as np
import xarray as xr
from brainscore_core.metrics import Score
from brainscore_vision.metrics import Ceiling
def _get_presentation_level(X, name: str):
"""
Return a 1D array aligned to 'presentation' for `name`, whether it is:
- a real coordinate on 'presentation', or
- a level of... |
fd70b2546aac0123b0279e907625e901990ac2c5f99871cc036b48a9f8f6e902 | Python | 3,884 | 120 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
from __future__ import annotations
from collections.abc import Callable, Iterable, Mapping, Sequence
from typing import Generic, TypeVar
import attrs
import numpy as np
_K = TypeVar("_K")
@attrs.define
class _BaggedCounter(Generic[_K]):
# St... |
7fe66cc2e0c7f072723ac77d83658a02fa47dc3e04cd9e74697c7e108ecf648f | Python | 3,885 | 95 | import numpy as np
from scipy import stats
def extendtooriginal(arrays, org_shape):
extended = []
for arr in arrays:
nans = np.full(org_shape, np.nan)
nans.flat[:arr.size] = arr
extended.append(nans)
return extended
def unitvector(xyarray, diff_step = 1):
"""
Computes unit ... |
a1cf7ab898a75055081e1d6beb6000a211cca0eca3b45f84992e475112803c53 | Python | 3,885 | 128 | #!/usr/bin/env python3
"""
Usage: ./check_denovo.py -s 14455_p1 -f size50_2_4.tsv.gz size50_2_4.tsv.gz size50_2_4.tsv.gz
"""
import argparse
import sys
import pandas as pd
TARGET_COL_NAMES = ['ORIGIN', 'DENOVO_CORRECTION', 'SUPPORT_COUNT', 'INHERITED_FROM_CORRECTION']
def check_inheritance(row, family_dict: dict):... |
db4446e2f0c455e976c3df90a74b1648e7c6d1f53d2741f09a9730a15d8afc60 | Python | 3,886 | 122 | import json
from pathlib import Path
from typing import Optional
import click
import nibabel
import numpy as np
import scipy
import skimage
from numpy.lib.stride_tricks import sliding_window_view
from simple_mri import load_mri
from gmri2fem.masking import create_csf_mask
def T1_lookup_table(
TRse: float, TI: f... |
13ac307bc36359001f3b3cdab3a9655f7ffd74f5e8626c55d69e5994b6cc5551 | Python | 3,887 | 116 | """ Cosine Scheduler
Cosine LR schedule with warmup, cycle/restarts, noise, k-decay.
Hacked together by / Copyright 2021 Ross Wightman
"""
import logging
import math
import numpy as np
import torch
from typing import List
from .scheduler import Scheduler
_logger = logging.getLogger(__name__)
class CosineLRSchedu... |
63dc6989fa230ec0adaa6bf5f32fe9f81b9dd847a2fdee86e4d001b19d79a6e1 | Python | 3,888 | 99 | import nilearn
import nilearn.regions
import nilearn.reporting
import itertools
import plotly
from scipy import ndimage
import fire
import sys
sys.path.insert(0,'..')
import pickle
from nilearn import plotting
from nilearn import surface
from nilearn.glm.thresholding import threshold_stats_img
import numpy as np
... |
9bd9c2a079c14d6c7392f731fd6a99970ffa6c62ad8916fc6b9fe50769383790 | Python | 3,888 | 112 | #!/usr/bin/env python
#
# Handles the destination dialog interface.
#
# Hazen 08/16
#
import paramiko
import sys
from PyQt5 import QtCore, QtGui, QtWidgets
import qtdesigner.destination_ui as destinationUi
class DestinationDialog(QtWidgets.QDialog):
def __init__(self):
QtWidgets.QDialog.__init__(self)... |
a5bcf42e0c7f6cb88c8326363f84493697499c9fb1fa1e7b0649cbf1f198cbd3 | Python | 3,888 | 118 | # Kai Sandbrink
# 2023-02-01
# This script samples trajectories across test tau values for the specified models
# %% LIBRARY IMPORTS
import torch
import pandas as pd
import numpy as np
from utils import Config, get_timestamp
from utils_project import load_config_files
from test_case import test, test_helplessness, pe... |
3191ce5a0689668df516f9272819f1909f913673ce2c9fc0875ae331612c4c34 | Python | 3,889 | 106 | # %%
# imports
import pandas as pd
# ML imports
from sklearn.preprocessing import power_transform
from sklearn.base import BaseEstimator, TransformerMixin
# %%
# functions
def add_power_transform(df, cols):
df.loc[:,cols] = power_transform(df.loc[:,cols])
return df.add_suffix("_tr") #pd.concat([df, pd.DataFr... |
85d7ec7c5497896b4c7497df8d715cee7a23bb43831fc684b7f13f85a4785229 | Python | 3,889 | 83 | import numpy as np
from brainscore_core.supported_data_standards.brainio.assemblies import BehavioralAssembly
from brainscore_core.supported_data_standards.brainio.packaging import package_data_assembly
import pandas as pd
'''
Experiment Information:
https://arxiv.org/pdf/1706.06969.pdf
- 4 subjects
- 1280 images ... |
ade6ca86e7d54ab6b99b393efd36a432322d025fb7d3c520759adf0f15ba02d8 | Python | 3,889 | 91 | from tests.common import *
class Test_AE_Pipeline:
def test_pipeline_no_run(self,demo_dir):
flag = False
LOGGER.info("run aberrantExpression pipeline with \'run: false\'")
# change the first instance of "run: true" to "run: false" to turn off the AE module
# run the AE module usin... |
b9b9af4d4e2c6f22cf98a32dbbf8d8bc22f0a03187f59e18ca810a9014a65637 | Python | 3,891 | 117 | """Custom optimizers for models."""
from typing import Any, Callable, Iterable, Optional
import torch
from torch.optim.optimizer import Optimizer
class EiSGD(Optimizer):
"""SGD optimizer variant with optional E-I clamping."""
def __init__(
self,
params: Iterable[torch.Tensor],
lr: f... |
cacc69a7221a421f5e3b586c9b78776e160b2af9d0e97cdb164d685323e60748 | Python | 3,891 | 106 | import os
import numpy as np
import pandas as pd
import time as tm
from sklearn.neighbors import KNeighborsClassifier
import rpy2.robjects as robjects
def run_kNN9(DataPath, LabelsPath, CV_RDataPath, OutputDir, GeneOrderPath = "", NumGenes = 0):
'''
run baseline classifiers: kNN
Wrapper script... |
57d6cc3b3d309e857e5ca671170f2f37983a8d9c3d5af957d14688524943d495 | Python | 3,893 | 114 | import re
from scipy.io import savemat
from sklearn.model_selection import StratifiedKFold
from tqdm import tqdm
from LocationRegressionHelper import *
import time
from numpy.random import default_rng
import argparse
import platform
import numpy as np
from pathlib import Path
# Import all regressors
# Linear regressio... |
66767fcb8d921ada8236cf83d92748cddf8c770175645660c7618c3e68aa5602 | Python | 3,893 | 99 | import shutil
import pytest
from hyperopt import hp
from torch.optim import SGD
from flair.embeddings import WordEmbeddings, StackedEmbeddings, FlairEmbeddings
from flair.hyperparameter import (
SearchSpace,
Parameter,
SequenceTaggerParamSelector,
TextClassifierParamSelector,
)
import flair.datasets
... |
a97b98e7ab01aeeb51f68b985c76a4a0d60d2c7bba965c1c771dbc505ad18b7f | Python | 3,893 | 184 | import os
from collections import OrderedDict
import numpy as np
import pandas as pd
import pytest
from impedancefitter import Fitter, get_equivalent_circuit_model
R = 1000.0
C = 1e-6
model = "parallel(R, C)"
Rc = 5.3e-6
dm = 7e-9
ecp = 60
kcp = 0.5
p = 0.2
km = 5e-11
em = 7.9
p = 0.1
kmed = 0.1
emed = 80
c0 = 1
k... |
788dc51ee1ade26a595896d8f4e883f4ed333b247619bce03eab473681e2b472 | Python | 3,894 | 116 | # import json
import sys
import json
import time
import requests
from urllib.parse import urlparse, urlencode
from urllib.request import urlopen, Request
from urllib.error import HTTPError
###Query CADD
def query_CADD(chr, pos, a1, a2, build):
if build.upper() == "HG19" or build.upper() == "GRCH37":
serve... |
f4feeb82e424972320896b7d0bc3eecc85eccc93c35b997eed15234a8ba3ec9f | Python | 3,894 | 114 | import os
import sys
import numpy as np
import time
import torch
#from knn_cuda import KNN
# add path
project_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if project_dir not in sys.path:
sys.path.append(project_dir)
def fetch_knn_points(point_cloud, knn_indices):
b, n, k = knn_indic... |
f9db628eb2e6e9d79ab4c2627726768214fe8216a8aebcf81e5f2b8339d14ffa | Python | 3,895 | 122 | '''
HOCO_Ar
'''
import numpy as np
import sys
def intro():
print("""
SHORT List of potential energy surfaces for HOCO_Ar:
P: potential energy, G: Gradient, D: Nonadiabatic coupling vector
This is listed at the end of description to show the availability.
For example: P/G means both potential ener... |
d3fb2d8baa8b9c344b3f4414d48e87146659553f59c299f912acd503048559f7 | Python | 3,896 | 141 | from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext
import os
from pathlib import Path
import platform
import re
import subprocess
import sys
from distutils.version import LooseVersion
with open("README.md") as readme_file:
readme = readme_file.read()
requirements = [
... |
a8078adc69e0e9f8a15b1ff73049c13df776d11130d4cfb75ca859fb3dc8eaec | Python | 3,897 | 89 | import torch
import torch.nn as nn
from torch.nn.parameter import Parameter
import pdb
class TrilinearScorer(nn.Module):
"""
Outer product version of trilinear function.
Trilinear attention layer.
"""
def __init__(self, input_size_1, input_size_2, input_size_3, init_std, rank=257, factorize = Fal... |
b6dc511790df302a1b4212a786eb4c04a92ad47b2f2511a8c3743d10b16ce00f | Python | 3,897 | 121 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
from __future__ import annotations
from abc import ABC, abstractmethod
from collections.abc import Mapping
from typing import Any, ClassVar
from attrs import frozen
class AttributeComparator(ABC):
name: ClassVar[str]
@abstractmethod
... |
cc197ce53190b2749e4e37e212e6de4d82b79ded18fd222e02bd4310f0b3e64c | Python | 3,897 | 115 | import os
import sys
import tempfile
import unittest
try:
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
except Exception:
sys.path.insert(0, os.path.dirname(os.path.abspath(".")))
from bx.arrays.array_tree import (
ArrayTree,
FileArrayTreeDict,
)
class TestArrayTree(unittest.TestCas... |
4ec07e72c2da1228a275af38554d66a2c43df93355a70cbe981d430b89a6a1e8 | Python | 3,900 | 133 | # -*- coding: utf-8 -*-
"""Resting-state utilities."""
import os
import nibabel as nb
from scipy.stats import zscore
from .. import execute_command
from ..io.filename import get_filename
from ..preprocessing.timeseries import bandpass_afni
__all__ = ["get_alff"]
def get_alff(file_in, TR, path_output, hp_freq=0.01... |
a9ca80ada8381b7e2c12a169175d688d3a0a15219b8ddb78ee5543d820fe92a7 | Python | 3,901 | 98 | from __future__ import print_function as _, division as _
import numpy as np
#in all of these functions, items or times is the spikeTime array (or shuffled array)
def histogram(items, bins):
"""Count items in [[bins[0], bins[1]),
[bins[0], bins[1]),
...
... |
05b2cdc7bc5ad6ec1a4df908bfce58605fc2810904a84b84e0978cb2a98a1a7e | Python | 3,902 | 106 | import os
import numpy as np
import pandas as pd
import time as tm
from sklearn.neighbors import KNeighborsClassifier
import rpy2.robjects as robjects
def run_kNN50(DataPath, LabelsPath, CV_RDataPath, OutputDir, GeneOrderPath = "", NumGenes = 0):
'''
run baseline classifiers: kNN
Wrapper scrip... |
593d067d9f945da3959fd6c08fca57626481558ab9ca1713cc091957b04de8bd | Python | 3,902 | 110 |
import numpy as np
import plotly.graph_objects as go
import pandas as pd
import re
from os import listdir
from pathlib import Path
ConSink = np.load(Path.cwd() / "data"/ "sink_rep_goal_low.npy")
n = ConSink.shape[0]
mypath = Path.cwd() / "data"/ "fig6c_nav_sim_result"
traj_list = np.array([str(mypath) + '/'+ f for f ... |
6c5ff0391bd41b51e88ffe32051dc1c5626d3a20cfa84251498961d8eb2446ec | Python | 3,902 | 124 | '''
Object category identification
This file is a part of GenericDecoding_demo.
'''
from __future__ import print_function
import os
import pickle
import numpy as np
import pandas as pd
import bdpy
from bdpy.stats import corrmat
import god_config as config
# Main ################################################... |
3a06436f72711aab5a1594ac263503aabbbbe1f2b40df5b25ceb852c07cc56aa | Python | 3,903 | 140 | # -*- coding: utf-8 -*-
"""AFNI realignment commands."""
from pathlib import Path
from fmri_tools import execute_command
from fmri_tools.io.vol import gzip_nii, gunzip_nii
__all__ = ["volreg", "allineate", "prepare_header", "extract_ref"]
def prepare_header(file_in):
"""This function handles potential oblique d... |
964306eca2309a4187c161fc8644339a4b0a224060e076fe524f3543078b9adf | Python | 3,903 | 131 | from .base import WaveformBenchmarkDataset
from .spectra_base import SpectrumBenchmarkDataset
# TODO: Add to documentation
CITATION = (
"Cianetti S., Mascandola C., Faenza L., Felicetta C., Russo E., Jozinović D., Münchmeyer J., Luzi L., "
"Michelini A. (2026). ESM25: A Machine-Learning-Ready Snapshot of the E... |
0633e7565c08255aab18946d550341e934d7492b3ffc1025ce6fda49aac2708e | Python | 3,904 | 159 | # The ImpedanceFitter is a package to fit impedance spectra to
# equivalent-circuit models using open-source software.
#
# Copyright (C) 2018, 2019 Leonard Thiele, leonard.thiele[AT]uni-rostock.de
# Copyright (C) 2018, 2019 Julius Zimmermann,
# julius.zimmermann[AT]uni-rost... |
89635b5977a6858ff7a092ece614db1240b2894545c43a1031b802eb75da8c78 | Python | 3,904 | 101 | from typing import Optional, Tuple
import torch
from pytorch_lightning import LightningDataModule
from torch.utils.data import ConcatDataset, DataLoader, Dataset, random_split
from torchvision.datasets import MNIST
from torchvision.transforms import transforms
class MNISTDataModule(LightningDataModule):
"""
... |
0bf268a6938fcb148e2566e21ad963ac90dd683e1783ff02073d4289ee38730b | Python | 3,905 | 140 | import shutil
from pathlib import Path
import flair
import flair.datasets
from flair.data import MultiCorpus
def test_load_imdb_data(tasks_base_path):
# get training, test and dev data
corpus = flair.datasets.ClassificationCorpus(
tasks_base_path / "imdb", in_memory=True
)
assert len(corpus.... |
5b89f4c2c839cd7f96ae7e97558d86d8cd92614517db2628599217e28c9470d0 | Python | 3,905 | 84 | import numpy as np
from brainscore_core.supported_data_standards.brainio.assemblies import BehavioralAssembly
from brainscore_core.supported_data_standards.brainio.packaging import package_data_assembly
import pandas as pd
'''
Experiment Information:
https://arxiv.org/pdf/1706.06969.pdf
- 4 subjects
- 1280 images... |
fcf1867f549718a3f8e32d439874f8e64d463efffcf64108e2fcaec9c77291cf | Python | 3,906 | 117 | import os
from copy import deepcopy
import numpy as np
import argparse
import innvestigate.utils as iutils
from keras.models import Model
from keras.preprocessing import image
from keras.utils import to_categorical
import keras
import tensorflow as tf
from numpy import average, dot, linalg
from utils import *
from lrp ... |
c1931cd91e025ffaa7ed452fefcb3b8c8a24750419e4aa23fdbea4c5833096a0 | Python | 3,907 | 128 | #Preprocessing
import os
import glob
import time
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import skew, kurtosis, gaussian_kde
start_time = time.time()
carpeta = r'C:\data'
if os.path.exists(carpeta):
os.chdir(carpeta)
else:
print(f"La ruta {carpeta} no existe.")
archivos = glob.g... |
ef8e86eb6edc9cee3e9794d6012d2dc911df158f028bd436deb6f88b8c465652 | Python | 3,907 | 125 | #!/usr/bin/python
#
## @file
#
# Compass 315M laser control. This is done via a
# National Instruments card as this laser does
# not come with any more sophisticated interface.
#
# Hazen 4/09
#
import sys
import time
import storm_control.sc_hardware.nationalInstruments.nicontrol as nicontrol
## Com... |
adf2bef662036ea5cca3cbd78b35682f06d46318fddb9b5ab4acc6e6b73ec009 | Python | 3,908 | 96 | import json
from websocket import WebSocket
from eir.setup.input_setup_modules.setup_sequence import get_sequence_split_function
from eir.setup.streaming_data_setup.streaming_data_utils import receive_with_timeout
from eir.utils.logging import get_logger
logger = get_logger(name=__name__)
def streamline_sequence_m... |
804f187f59cbca2773cb83e9630f2b4eb14a42ed633fe5c4be6553c4225f43fb | Python | 3,909 | 73 | # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'scmos-calibration.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.se... |
a7eb312e40c64a352611fc06ff17d686b4a6dd292934f95a1b1cd74a74fd4d4b | Python | 3,909 | 104 | import numpy as np
def prestim_passive(aRec,pre_stim=1.):
return np.vstack([aRec.ttmat[:, 0] - pre_stim, aRec.ttmat[:, 0]]).T
def stim_passive(aRec,post_stim=0.8):
return np.vstack([aRec.ttmat[:, 0], aRec.ttmat[:, 1]+post_stim]).T
def baseline_passive(aRec,post_marg=1.):
return aRec.interttmat[1:-1]+np.... |
027f6d3444f1ff90d8eb1cb6648f2672b34c5d1cc47b38e6dc746c7a83bb4760 | Python | 3,910 | 88 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
from typing import Any
import cv2
import numpy as np
from ultralytics.solutions.solutions import BaseSolution, SolutionAnnotator, SolutionResults
from ultralytics.utils.plotting import colors
class TrackZone(BaseSolution):
"""A class to manage... |
cb00318d0dd7adc50ae60786c53d2900c5424e7438f8d80eedfc4596b243e56b | Python | 3,910 | 98 | """Per-subject persubject-pool preparation for the LAION-fMRI benchmark.
Twin of :mod:`prepare_shared` for the *persubject* stim pool (each subject's
own ~6,204 stimuli: 1,121 shared non-OOD + 4,712 subject-unique + 371 OOD).
The persubject pool drives the headline ridge benchmark (see
``benchmarks/laion_fmri/METHODS.... |
de8eb9b50b94aefebea69bcd46b7e52cc8026ec3ae0be7dab87cdada8ff01d1c | Python | 3,910 | 166 | #!/usr/bin/env python2
import struct
import array
import sys
import subprocess
import signal
import os
import numpy as np
from optparse import OptionParser
###############################################################################
# Helper function to run commands, handle return values and print to log file
def... |
01875538e1dbe33c6ed5b6ee01dbda34d677fbedc209fd556cb078641ea800b6 | Python | 3,911 | 127 | """
Logging configuration for the stack-corr application.
"""
import logging
import sys
from pathlib import Path
from typing import Optional
class ColoredFormatter(logging.Formatter):
"""Custom formatter that adds colors to log levels."""
COLORS = {
"DEBUG": "\033[36m", # Cyan
"INFO": "\033... |
297f69364652df0b978e1ffec08c1ec55b74c2c78cc3ada4fa439d8e0c36c0f3 | Python | 3,911 | 102 | from readers.Readers import Reader
from writers.Writers import Writer
from mesh.Node import Node
from mesh.Mesh import Mesh
from mesh.Element import Element
from vtk import vtkIdList, vtkUnstructuredGridReader
from os.path import exists
from mesh.mesh_transformations import translate_mesh
def readVtk(path, filename):
... |
3576bff04c0d3ff8727207a90785fda2fcd9a95c2f575ac5b448d8afa99f708d | Python | 3,912 | 84 | import numpy as np
from brainscore_core.supported_data_standards.brainio.assemblies import BehavioralAssembly
from brainscore_core.supported_data_standards.brainio.packaging import package_data_assembly
import pandas as pd
'''
Experiment Information:
https://arxiv.org/pdf/1706.06969.pdf
- 4 subjects
- 1280 images... |
6caa874cb68e923c1b726852c351d73078bb473143f6695801e92d84f083c6e6 | Python | 3,912 | 120 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
"""Pre-download shared test assets to avoid race conditions under pytest-xdist.
Run this script once before `pytest -n auto` to ensure all model weights,
datasets, and solution assets are already cached locally. Each xdist worker
can then reuse existi... |
2427935104d9553bd7663ae60594a767c97073e71ddd28edaaf97ecc01fa3071 | Python | 3,914 | 112 | import numpy as np
import pandas as pd
from mc_analysis.simulator.g1_simulator import (
G1Simulator,
bin_tofs,
to_G1_jacobian,
to_G1_jacobian_cw,
to_G1_jacobian_cw_dask,
to_G1_jacobian_dask,
)
from mc_analysis.simulator.mch_to_csv import mch_to_df
def get_td_jac(aDb, basename, lags, mua, refr... |
fcf241bf7e43c94da0832ffb2b4246acdf6903003fd0bef04e3708bc711be052 | Python | 3,914 | 125 | from typing import Tuple
import numpy as np
import torch.nn.functional
from numpy.typing import NDArray
def homog_indices(s0: int, s1: int, s2: int) -> NDArray:
idxs = np.mgrid[:s0, :s1, :s2, 1:2].reshape(-1, s0 * s1 * s2)
return idxs.astype(np.int32)
def translate(idxs: NDArray, t0: float, t1: float, t2: ... |
91bd56c476984993706a25f1d7089643e505ab91e879599db2d27bb74a7d6fd3 | Python | 3,915 | 86 | #!/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
fetch_data(get_testing_files_dict(), keys=['commit_amico.zip'])
tmp_dir = tempfile.TemporaryDirectory()
def test_help_option(script_runner):
r... |
661e84ed37ab81e31aedbde7e02bb8f7d9b748029c273b653252feeefb986e56 | Python | 3,916 | 124 | """"Plot BFI and correlation vs ToF for different ToF values."""
import numpy as np
from matplotlib import gridspec
from matplotlib import pyplot as plt
from mc_analysis.fitting.correlation_metrics import get_td_metrics
from mc_analysis.fitting.loaders import load_fit
from mc_analysis.utils.absolute_paths import DATA_... |
1b0d7357b81ae167de592a75ed37e3c8e1bfdc37c9bc4a40480fdbb07c70d9f0 | Python | 3,917 | 117 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
"""
This script lists resources on the CVAT server
and saves them to JSON files in the `assets` directory.
Before running it, start the test instance by running:
pytest tests/python --start-services
The script determines which endpoints to quer... |
46866010bd786d52db2918edb2e7af0e464e4039f6204a373fd50258ff66ce1c | Python | 3,917 | 125 | from __future__ import annotations
import numpy as np
import pytest
from labelme._shape import Shape
from labelme._shape import can_merge_shapes
from labelme._shape import merge_masks
def _full_mask(*, xmin: float, ymin: float, size: int, label: str) -> Shape:
return Shape(
label=label,
shape_ty... |
38c58877e33c96610230b162f657b89f2e44635aac0fc64b4c6d7e0cc31aab82 | Python | 3,918 | 108 | import numpy as np
import nibabel as nib
import SimpleITK as sitk
import os
from termcolor import colored
try:
from keras import backend as K
from keras.models import *
from tensorflow.python.client import device_lib
except Exception as e:
print(e)
print('-' * 100)
print(colored("""ERROR: Failed ... |
cbd5650edd751514f7241ea80318a6e06363ad027718953c4463de68c87163f9 | Python | 3,918 | 131 | """
This is ported from Matlab code from the original TDR codebase.
"""
import numpy as np
from math import floor
from scipy.signal import convolve
from scipy.signal.windows import gaussian
def temporal_smooth(data):
# Smoothing parameters
smthpars = {}
smthpars["filter"] = "gauss" # {'gauss';'box'}
... |
4457915d4ef7d4e65aef3dea4fce82a7e1b2c5697f1f60ca8099d34dc0449bb1 | Python | 3,919 | 92 | from typing import Tuple
import torch
from batchgeneratorsv2.helpers.scalar_type import RandomScalar, sample_scalar
from batchgeneratorsv2.transforms.base.basic_transform import ImageOnlyTransform
from torch.nn.functional import interpolate
class SimulateLowResolutionTransform(ImageOnlyTransform):
def __init__(... |
521367aea56ae4d4146a1ee4aa4b691d12e0a654dfe9fc4bf0863850a98e6655 | Python | 3,919 | 110 | import os
from sys import argv
from pathlib import Path
import numpy as np
import pandas as pd
import time as tm
from sklearn.svm import LinearSVC
import rpy2.robjects as robjects
from sklearn.calibration import CalibratedClassifierCV
def run_SVM(DataPath, LabelsPath, CV_RDataPath, OutputDir, GeneOrderPa... |
c944149d64426918c12974e404a01d72175a78b980fbdaedb0ba5b0a033b2c95 | Python | 3,919 | 94 | #!/usr/bin/env python3
# -*- coding: utf-8
"""
Script that runs DestVI on simulated data.
Created on 2020/02/03
@author romain_lopez
"""
import os
import click
import numpy as np
import scanpy as sc
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import anndata
import scvi
from scvi.model... |
fd9375dc432215aabcfbe5ca99d82e811edcdf036d18d4b9e5aa768e2214703b | Python | 3,919 | 133 | # SPDX-FileCopyrightText: Copyright © Jørgen Riseth and Timo Koch
# SPDX-License-Identifier: GPL-3.0-or-later
"""
Download data from Zenodo.
In case the data is not publicly avaiable yet, set the
access token in the environment e.g. by calling:
ZENODO_ACCESS_TOKEN=<your_token> python zenodo_download.py
"""
import ar... |
27410d01f57433edae4900552cc3b71a8713b76f424b510c306138d918ea14fc | Python | 3,920 | 94 | # Copyright 2024 Google LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
7552328ef810611438b889545ce7ab488e5a6e2feffb67ccac8229d107093a97 | Python | 3,920 | 91 | """
Adapted from the NSuite benchmarking framework (https://github.com/arbor-sim/nsuite.git)
"""
import json
def from_json(o, key):
if key in o:
return o[key]
else:
raise Exception(str('parameter "'+ key+ '" not in input file'))
class cell_parameters:
def __repr__(self):
s = "cell... |
a2b2e52b36a29462874ed0db05a8642c348606a94d584c4798a111ad3714ae1d | Python | 3,920 | 105 | from __future__ import annotations
import typing
from typing import Final
import pytest
from labelme._ai_models import AI_ASSIST_MODEL_OPTIONS
from labelme._config import load_config
from labelme._config._schema import SETTINGS
from labelme._config._schema import Group
from labelme._config._schema import Setting
@... |
cacfe2613edecd1aeca4550d9d8e56bb0218bc0958e2726acba91202923670fb | Python | 3,920 | 123 | '''
N2HOC+ (or N2HOCp)
'''
import numpy as np
import sys
def intro():
print("""
SHORT List of potential energy surfaces for N2HOCp:
P: potential energy, G: Gradient, D: Nonadiabatic coupling vector
This is listed at the end of description to show the availability.
For example: P/G means both pote... |
d7230a13f64c3fe26902939a650009807cf9d99b82f4343f036fff8a3b2efd20 | Python | 3,920 | 89 | """
Predicted concentration vs estimated concentrations
for the Look Locker and Mixed sequences with a given SNR
"""
import click
import numpy as np
from plot_noise_look_locker import generate_look_locker_data
from plot_noise_mixed import generate_mixed_data
def tabulate_estimated_versus_actual(snr, samples, sequenc... |
a18964e64393bf9f55dc0aa533055df741a288b0974fabcf7f665ee85386353f | Python | 3,921 | 99 | '''Tests for torchvision-model-specific canonizers.'''
import pytest
import torch
from torchvision.models import vgg11_bn, resnet18, resnet50
from torchvision.models.resnet import BasicBlock as ResNetBasicBlock, Bottleneck as ResNetBottleneck
from helpers import assert_identity_hook, randomize_bnorm, nograd
from zenni... |
4e308aa63941b2156e4730ba9b2db691ba322f3e5ad811b2ccc2a6271827d5a0 | Python | 3,922 | 109 | from typing import Optional, Tuple, List
import torch
def onnx_forward(onnx_file, example_input):
import onnxruntime
sess_options = onnxruntime.SessionOptions()
session = onnxruntime.InferenceSession(onnx_file, sess_options)
input_name = session.get_inputs()[0].name
output = session.run([], {inp... |
56de32391b34fa3efcd94054fe8350bb3a56a46361d1316762a1de44648656cf | Python | 3,922 | 114 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
from abc import ABC, abstractmethod
from typing import TypedDict
from django.db import transaction
from django.db.models import Count, Q, QuerySet
from cvat.apps.engine.models import CloudStorage, Project, Task
from cvat.apps.iam.models import User... |
d7a6096383b172f4583250f5ea8366135e0bb1b9603f878ac9dee5d23b2e0c4b | Python | 3,922 | 124 | from pydesigner.system.models import (
modelmrtrix,
input_path_validator,
output_path_validator,
)
from pydesigner.system.errors import FileExtensionError
from pydantic import ValidationError
import pytest
from conftest import load_data
DATA = load_data(type="hifi")
PATH_DWI = DATA["nifti"]
def test_mode... |
1c63ee3df32107f5f3fb4cb3487188135a555fd8a0c8b0b7fb7e086ccfe3846b | Python | 3,923 | 71 | import os
import subprocess
import shutil
import nibabel as nib
import time
import numpy as np
import pandas as pd
from nipype import Node, Workflow
from nipype.interfaces.base import BaseInterface, BaseInterfaceInputSpec, TraitedSpec, File, Directory, traits, CommandLineInputSpec, File, TraitedSpec, CommandLine, Direc... |
2c52d4346aedc87517a5f01be89eefe088a874b15b378f79397400e58867e8f4 | Python | 3,923 | 105 | import os
import torch
import pandas as pd
import torch.nn as nn
from ecg_utils import get_dataloaders, DATASET_PATH
from proto_models1D import ProtoECGNet1D
from proto_models2D import ProtoECGNet2D
class FusionProtoClassifier(nn.Module):
def __init__(self, model_1d, model_2d_partial, model_2d_global, num_classes=... |
6d96a4e8297fc325780debd89f11c4980ec90688b2fc3e3a80c6a7bcfc68f315 | Python | 3,923 | 90 | import os
import shutil
import json
import numpy as np
import nibabel as nib
from scipy.ndimage import zoom
from utilities.data_simulation.Download_data import download_data
DIFFUSIVE_REGIME = 'diffusive'
BALLISTIC_REGIME = 'ballistic'
def simulate_brain_phantom(regime=DIFFUSIVE_REGIME, snr=100, sim_relaxation=True, ... |
8da43c39f68108209d293a59b1bc95c3d9629d2597f931d861c0445e0baedbd6 | Python | 3,923 | 118 | import os
import yaml
import h5py
import sys
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
run1 = 'runC00dMP3_brain'
stags = ['Carlen','IBL']
if run1.count('dMP'):
ncluststr = '8'
run2 = 'runIBLPasdMP3_brain_pj'
else:
ncluststr = '5'
run2 = 'runIBLPasdMI3_brain_pj'
cmetho... |
176b9b5d972ca06b02c076f687d5fb7896784c2dcdbc1448507d5be6c5b88d20 | Python | 3,925 | 106 | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import numpy as np
import cv2
import onnxruntime
from typing import Optional, Tuple
from ..utils.transforms import Resiz... |
0cba7411ff0907ba5e37e74b4a02a3fb187ad34d89da20ff47fa3d2aa88252fa | Python | 3,927 | 141 | # myelinfccoupling/cli.py
import click
from pathlib import Path
from .io import load_inputs
from .config import Config
from . import model, binning
from .util import ensure_dir, sanitize_label, save_struct_by_level
@click.command()
@click.option(
"--edges",
type=click.Path(exists=True, readable=True),
r... |
1f3a6c8ab98b75740685a14982807f6daa5cc081886022d0a20bcbcd579f02a2 | Python | 3,927 | 124 | #!/usr/bin/env python3
"""
Example: run ORCA geometry optimization from an input XYZ.
This script writes an ORCA input file like:
! r2SCAN-3c TightSCF OPT
# ! CPCM(water) # uncomment and set solvent if desired
%maxcore 7000
%pal
nprocs 8
end
* xyzfile 0 1 input.xyz
Usage:
python examples/conform... |
88d39a7b1155572f9bfef9db05ac2f2f5240ab149a17d95cc1486f355ba07a19 | Python | 3,927 | 147 | #!/usr/bin/env python
"""
Unit tests for corr_2d_gauss_c
Hazen 09/19
"""
import numpy
import storm_control.sc_hardware.utility.corr_2d_gauss_c as corr2DGauss
def test_xy_derivatives():
im_size = (9,9)
c2dg_py = corr2DGauss.Corr2DGaussPy(size = im_size, sigma = 1.0)
x = numpy.zeros(2)
image = c2dg_p... |
8a0738b3c02fbcdd79946ea6bcd549382ed6e7c141f283c738498a5ae2f899ac | Python | 3,927 | 114 | """
Helper to load large arrays preferring zarr datasets when available.
Provides load_array(path, ...) which will try to open a .zarr dataset (or sibling .zarr)
and fall back to numpy.load(..., mmap_mode=...).
Returns either a zarr Array/Group or a numpy array/memmap depending on what was loaded.
"""
from __future__ ... |
b2ce3f1b5abc8349675dc1a4723c2b2c1d2198ab899807031687a3794833ce3d | Python | 3,927 | 142 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
import json
import logging
from pathlib import Path
import altair as alt
import pandas as pd
from quilt3 import Package
###############################################################################
logging.basicConfig(
level=logging.INFO,
forma... |
0f2e169b5f01b20d967917530a9bd8d6218f7fccb654c2d70a683ad47afd71e0 | Python | 3,928 | 77 | import h5py
import numpy as np
import xarray as xr
from pathlib import Path
from brainscore_core.supported_data_standards.brainio import get_assembly
from brainscore_core.supported_data_standards.brainio.assemblies import NeuronRecordingAssembly
from brainscore_core.supported_data_standards.brainio.packaging import pa... |
f75e49e5ec3621d18ca8c42ca3a2fe8c42d85448f9180d187ed06011a373c409 | Python | 3,929 | 94 | import logging
from zigzag.classes.opt.spatial.generator import UserSpatialMappingGenerator
from zigzag.classes.stages.Stage import Stage
from zigzag.classes.stages.SpatialMappingConversionStage import (
SpatialMappingConversionStage,
)
import copy
logger = logging.getLogger(__name__)
class SpatialMappingGenera... |
8b45700f25498e71e6ae60be2e9fce3a4a33f070b81da36d91566e9444c105ad | Python | 3,930 | 140 | import os
import shutil
import zipfile
import nibabel as nib
from scipy import ndimage
from tensorflow.keras.utils import get_file
output_pixdim = 1.5
PROJECT_DIR = "demos/grouped_mr_heart"
os.chdir(PROJECT_DIR)
ORIGIN = "https://github.com/ucl-candi/datasets_deepreg_demo/archive/myops.zip"
ZIP_PATH = "myops.zip"
D... |
b1ef7025d62a2cb13cc77d6116993653100e966e754d5db2d3a05d1e75e97c64 | Python | 3,931 | 111 | """Build distributions and read skills without an editable source checkout."""
import hashlib
import os
from pathlib import Path
import shutil
import subprocess
import sys
import tarfile
import zipfile
import pytest
@pytest.fixture(scope="module")
def skill_distributions(tmp_path_factory):
root = Path(__file__)... |
8e5e1051ee2e28cc616891535664080f399eba603f6b8479b03e5f84fd40e123 | Python | 3,932 | 108 | import inspect
import argparse
import re
from logging import info, warn
from json import dumps
from hashlib import md5
class Settings(object):
def __init__(self, values=None):
"""Return Settings with given values."""
if isinstance(values, object):
values = vars(values)
elif not... |
ef6d07d7649031673e86b526e74b8a7586038c213cf9cdfe2d1c617c0fbd4189 | Python | 3,932 | 118 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
"""Upload utilities for Ultralytics, mirroring downloads.py patterns."""
from __future__ import annotations
import os
from pathlib import Path
from time import sleep
from ultralytics.utils import LOGGER, TQDM
class _ProgressReader:
"""File wra... |
1bb3291e1360384ff62fc82fc20eeed9a186bd1f0ae822e94c013dbbd66e84e5 | Python | 3,933 | 92 | from src.wrappers.OsipiBase import OsipiBase
from super_ivim_dc.source.Classsic_ivim_fit import IVIM_fit_sls_BOBYQA
import warnings
import numpy as np
class TCML_TechnionIIT_lsq_sls_BOBYQA(OsipiBase):
"""
TCML_TechnionIIT_lsqlm fitting algorithm by Angeleene Ang, Moti Freiman and Noam Korngut, TechnionIIT
... |
3ae53dee397c0946b5c005fe8126cb5b5f212d5bbaf4d8a83b47cc2482397a4c | Python | 3,934 | 58 | from .activations import *
from .adaptive_avgmax_pool import \
adaptive_avgmax_pool2d, select_adaptive_pool2d, AdaptiveAvgMaxPool2d, SelectAdaptivePool2d
from .attention2d import MultiQueryAttention2d, Attention2d, MultiQueryAttentionV2
from .attention_pool import AttentionPoolLatent
from .attention_pool2d import A... |
3fcf5a1f08ae2478a5e680d605040cb8bd448c4b18913174a8baa14e41c2b8b8 | Python | 3,934 | 128 | """Plot NSD-synthetic and NSD-core's NCSNR.
Parameters
----------
subjects : list
List with all used NSD subject.
zscore : int
Whether to z-score [1] or not [0] the fMRI responses of each vertex across
the trials of each session.
project_dir : str
Directory of the project folder.
"""
import argparse
import os
im... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.