sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
869a1893fb0ae9431a95a5ad1ab3141405175c385c369bd1f7cf4e7509bac316 | Python | 8,367 | 327 | # 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 dateutil
import math
impor... |
a79a39bbea5430ae20a6f030637fdb2d7840bec364547fa9a9f46abf8f055de8 | Python | 8,367 | 241 | # -*- coding: utf-8 -*-
import itertools
import logging
import bct
import numpy as np
from scipy.stats import t as stats_t
from statsmodels.stats.multitest import multipletests
from scilpy.tractanalysis.reproducibility_measures import compute_dice_voxel
def _ttest_stat_only(x, y, tail):
t = np.mean(x) - np.mea... |
5e3104b9fd4b1c6bea482bff16fc64d769398594ab15c763ff7663c2dc95991c | Python | 8,371 | 234 | # Copyright (C) 2021-2022 Intel Corporation
# Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import io
from collections.abc import Callable, Mapping
from contextlib import nullcontext
from typing import Any
import rq
from datumaro.components.errors import DatasetError, DatasetImportError, DatasetN... |
d4d4ef47fb21a7e2f7c80275caf107d22eea9233f36ae80dca017f4b0bbddb16 | Python | 8,371 | 187 | # 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... |
074b864192abce1db3af47054bc9f7547f89423435c04797951518db758c5d78 | Python | 8,375 | 220 |
import mmcv
import copy
import torch
import numpy as np
import torch.nn as nn
from abc import ABCMeta, abstractmethod
from mmcv.runner import BaseModule, auto_fp16, force_fp32
from mmcv.cnn import ConvModule
from depth.ops import resize
from depth.models.builder import build_loss
class DepthBaseDecodeHead(Ba... |
933a344359ddaca93f5e12714573ce73eaa1b0e3ff94ee167f9e0da5cbcb774a | Python | 8,375 | 154 | import sys
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from .internals import *
from .components import __get_figax
from typing import Union, Callable, Dict
# grab module
__pub = sys.modules['pubplot']
def __sig_from_p(p: Union[str, float]) -> str:
'''
'''
sig = p if type(p... |
23a12b7d95af7a7d53332d149f50ac962450a81ffa08d10e67b8f53aa2b95b67 | Python | 8,376 | 250 | #!/usr/bin/env python
"""
ctypes interace to a Mad City Labs piezo stage.
Hazen 3/09
"""
import ctypes
import time
import storm_control.sc_library.halExceptions as halExceptions
class MCLException(halExceptions.HardwareException):
pass
class ProductInformation(ctypes.Structure):
"""
... |
4a45eec4dd1008cf84774757fed538a25782a946571ee20067596873d5e9e0cb | Python | 8,378 | 250 | #!/usr/bin/env python
"""
ctypes interace to a Mad City Labs piezo stage.
Hazen 3/09
"""
import ctypes
import time
import storm_control.sc_library.halExceptions as halExceptions
class MCLException(halExceptions.HardwareException):
pass
class ProductInformation(ctypes.Structure):
"""
... |
86f1719df51b9176dc2c62c6fc54a01a12bcf7f02d1d9791a69a99b8c39a27d3 | Python | 8,378 | 255 |
# This library implements "baseline" agents to be compared with the metaMDP
# in the visual search in VR experiment. Since much of the architecture of the models
# is the same, we re-use the MetaMDP agent class.
#
# Authors: Angela Radulescu
import numpy as np
import sys
# from sklearn.metrics.pairwise import euclid... |
00aa58cec8acca05101d594f69ff68e58e6689fe79ec29fbb2ba25d81f872e33 | Python | 8,380 | 268 | #!/usr/bin/env python3
import pandas as pd
import numpy as np
import random
import os
import math
import tensorflow as tf
import keras
from keras import layers
#import autoAnalysis
#from autoAnalysis import run_experiment
from tensorflow import data as tf_data
#
from keras.layers import StringLookup
from sklearn impor... |
009af9e9c98ea5886580fa16a298065a086706d52c13d60ddca2a62fd2e0fcb7 | Python | 8,381 | 271 | from collections.abc import Sequence
from functools import partial
from pathlib import Path
from docs.doc_modules.experiments import AutoDocExperimentInfo, run_capture_and_save
from docs.doc_modules.serve_experiments_utils import copy_inputs, load_data_for_serve
from docs.doc_modules.serving_experiments import (
A... |
20a5962ff5f84d80ee049ed95fe2dc63aa85616822a98d54f6e48d9173cb7e32 | Python | 8,381 | 240 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import os
from datetime import timedelta
from io import BytesIO
from pathlib import Path
from unittest import mock
import packaging.version as pv
import pytest
from cvat_cli._internal.agent import (
_Event,
_NewReconnectionDelay,
_parse_... |
8f319e2aea720bf12b54af716cf07fff9e397fb71677173a7734b6b90de80a50 | Python | 8,382 | 230 | """
This script converts the output from predict_DANNCE into a predescribed
structured data format, with meta data, that can be used easily by our
downstream analysis pipeline
Usage:
python path_to_file/makeStructuredData.py path_to_config [bool_3cams]
Optional: if bool_3cams is present and True, saved 3-cam predicti... |
7b1b498c3a5a6541119e13a8b87eba8f30ebd55c2ef325ae8d271431a11e1cf9 | Python | 8,383 | 219 | """Select NSD-core's OOD test images using k-means clustering on the fMRI
responses in MDS space.
Parameters
----------
subject : int
Number of the used subject.
data_ood_selection : str
If 'fmri', the ID/OD splits are defined based on fMRI responses.
If 'dnn', the ID/OD splits are defined based on DNN features.
zs... |
8785cdb5b459e78298f401190f2f73d68bfd26f624446dbaa8f3b62408afc2fb | Python | 8,386 | 253 | import numpy as np
eps = 1e-6
def projection(va, vb):
return np.dot(va, vb.T) / np.dot(vb, vb.T) * vb
def get_rotation_matrix(theta, d):
x, y, z = d[0], d[1], d[2]
M = np.zeros((3, 3))
cos, sin = np.cos(theta), np.sin(theta)
M[0][0] = cos + (1 - cos) * x * x
M[0][1] = (1 - cos) * x * y - si... |
d35c0236b64e6152bc9ab946a6c7fc94aca41c33056c7f3dd944619f36fa62c8 | Python | 8,387 | 191 | #This script will create an index (.ndx) file that contains the atoms needed to calculate omega angles.
#Then the index file is input for the GROMACS command "gmx angle", which will calulate the omega angles
#and output a .xvg file containing the omega angles for each residue for each frame in the trajectory.
#Finally... |
10d9b87edf515dcd5284a64d2eec7c4095107b164834e6f962ecbd6474907a98 | Python | 8,388 | 211 | '''
FibrosisNet Evaluation Script
This python script allows users to perform evaluation
using the FibrosisNet ensemble
This script uses CT_WEIGHT=1.0 because that gives the
best performance on the kaggle submission.
'''
import os
import sys
import random
import math
import cv2
import argparse
import tensorflow.comp... |
adbdeb4c89a556023a1511ba836e051b25e2ccea5e093f38627deb86d01a2c06 | Python | 8,390 | 205 | #! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Compute NODDI [1] maps using AMICO.
Multi-shell DWI necessary.
---------------------------------------------------------------
Reference:
[1] Zhang H, Schneider T, Wheeler-Kingshott CA, Alexander DC.
NODDI: practical in vivo neurite orientation dispersion
and... |
ae20c5f621fe89f5e33fb6e699a18495812f62af6772451ea603c671735e3fbf | Python | 8,392 | 231 |
"""
This class handles the overlay of highlights and the brain area name in the status bar.
This enables more than one plugin to use these features.
"""
import numpy as np
import pyqtgraph as pg
import os.path
#For handling the labels files
import lasagna.tree
import lasagna.io_libs.ara_json
#For contour draw... |
2ce0e65d9e22ba44b29ce4517da8b741c812a34f4568509d6c80ce62010f4914 | Python | 8,393 | 248 | """Test QtGui."""
import sys
import pytest
from qtpy import (
PYQT5,
PYQT_VERSION,
PYSIDE2,
PYSIDE6,
QT_VERSION,
QtCore,
QtGui,
QtWidgets,
_parse_version,
)
def test_qfontmetrics_width(qtbot):
"""Test QFontMetrics and QFontMetricsF width"""
assert QtGui.QFontMetrics.widt... |
57eba31da0d5e5c85a2168e9ab73be28c4d16b401f03410ad8bbd6aa33bc3efc | Python | 8,393 | 220 | import numpy as np
class GenerateData:
"""
Generate exponential and linear data
"""
def __init__(self, operator=None, rng=None):
"""
Parameters
----------
operator : numpy or torch
Must provide mathematical operators
rng : random number generator
... |
84c8843f5fc37d48bdbc8ccad917e69071ee893fc527596efdbb853be59aabd8 | Python | 8,393 | 175 | import argparse
import utils # shap is imported by utils, must be imported before keras
import keras
from keras.models import load_model
import gc
import os
import numpy as np
import h5py
import pandas as pd
from tensorflow import Variable
import pandas as pd
from os.path import join
"""
Run Attribution Analysis on an... |
bf1fa1990c617e6efec93a4b91890aa56d5148cde143b70894bf7bacbba52132 | Python | 8,394 | 216 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Script to sample SF values from a Spherical Harmonics signal. Outputs a Nifti
file with the SF values and an associated .bvec file with the chosen
directions.
If converting from SH to a DWI-like SF volume, --in_bval and --in_b0 need
to be provided to concatenate the b... |
c56f5b95fd6b2c5da39eb7ddc0be617cfb236ef4c521c19e029fb29ca303935a | Python | 8,396 | 240 | # 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 torch
from torch import Tensor, nn
import math
from typing import Tuple, Type
from .common import MLPBlock
clas... |
ccafa092603a0c00ae9bd1ca4cad6ab04a409bea35ef7a03ac503263d6171d56 | Python | 8,396 | 227 | """Regression tests for issue #20 -- ``project_volume`` corrupting its input.
``paths`` is zero-padded on the right and flat index 0 is reserved as "no
voxel", so a max/min reduction has to keep the padded entries from being
selected. It used to do that by writing the dtype's extreme value into
``volume.flat[0]`` and ... |
5936b442ffdc9d102f0f92fd8dbb7db0bd9daf9dd6acbaee22a09ad27ed834c9 | Python | 8,397 | 204 | # 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-rostock.de
#
# This program is free softwa... |
630eadcb3e5c7ec0077b31114b8266c8cf22623cb4e9c71ddf981f6772827a90 | Python | 8,398 | 207 | # 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, ... |
6f3228a1052238c0d548fa01e730dae4e997708157a917308c0099f8a44e299d | Python | 8,399 | 279 | import sys
import ast
import numpy
import queue
import typing
import asyncio
import traceback
import threading
import logging
import multiprocessing
from matplotlib.figure import Figure
from thalamus.qt import *
from ..thalamus_pb2 import StimRequest, AnalogResponse, Span, NodeSelector
from ..thalamus_pb2_grpc import... |
996e4240690d5229bdbc883d81f73c86df453c43582475358c353273e20cde1f | Python | 8,400 | 244 | # Copyright 2017 Calico 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... |
8eb9b5c565a08c883a365d7860eef9861a602b1e299d06069eb974e185e229eb | Python | 8,402 | 206 | # -*- coding: utf-8 -*-
"""
Generate settings and wiring JSON files to be used in the Megazord pipeline.
Settings JSON file
------------------------
SPIKE SORTER
Which spike sorter SpikeInterface should use, default is Kilosort 2.5, for options see:
https://spikeinterface.readthedocs.io/en/latest/modules/sorte... |
d01994177a8511f576b142081ccbf6d2f2fb8f63ddcad0a35dc3a5911bfd29ad | Python | 8,404 | 241 | # Generated by Django 4.2.18 on 2025-02-17 18:01
from datetime import datetime, timezone
import django.db.models.deletion
import django.utils.timezone
from django.db import migrations, models
def add_timestamps_to_settings(apps, schema_editor):
QualitySettings = apps.get_model("quality_control", "QualitySetting... |
b7d1ba2a78d21413e3dc5322738e0e8c7878130c4b18b139ec753a42a681a625 | Python | 8,406 | 256 | #!/usr/bin/env python
# author: Jannes Spangenberg
# github: https://github.com/JannesSP
# website: https://jannessp.github.io
import numpy as np
import pandas as pd
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import seaborn as sns
import sys
from os.path import join, dirname
from dynamont ... |
a57eed794476eb0e59f2d0d8868c744fcdc5a4900b257ff4e1e6cc839696baac | Python | 8,407 | 225 | import sys
import yaml
import os
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
pathpath,myrun,ncluststr,cmethod = sys.argv[1:]
ncl = int(ncluststr)
with open(pathpath) as yfile: pathdict = yaml.safe_load(yfile)
rundict_path = pathdict['configs']['rundicts']
srcdir = pathdict['src_dirs'... |
cff6a215d49b3ab526b1f026017263e151e66493f5e788364c94d7600ea0d223 | Python | 8,408 | 212 | #############################################################################
# Copyright (C) 2020-2026 MEmilio
#
# Authors: Martin J. Kuehn
#
# Contact: Martin J. Kuehn <Martin.Kuehn@DLR.de>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Li... |
09c7c5627dc58e5c58b4190a846cd8aa3bf6ab51d1d944d4228bf8c31dec964c | Python | 8,409 | 213 | import numpy as np
def crop(data: np.ndarray, patch_size: int = 128, overlap = (0.5, 0.5), dry_run=False) -> np.ndarray:
"""
Crop a 3D volume into overlapping 2D patches.
The function extracts 2D patches from each slice (z-plane) of the input volume,
with a specified patch size and overlap fractio... |
42f18eb64bc3609da02da0327c547cd7a493321fc52330f3e28d69741f05f771 | Python | 8,409 | 206 | import numpy as np
from scipy.optimize import nnls
from sklearn.metrics.pairwise import euclidean_distances
class Model:
''' Non-negative Basis Function Regression
'''
def __init__(self, location, l=5.0):
self.l = l
self.weights = None
self.centers = None
self.location = location
def fit(self, stim_de... |
c83bce56a136df22842ed429c861fbf7753b55407f016c987ae98fac896e3698 | Python | 8,410 | 267 | ########################################################################################
### Utility function for different purposes regarding the reading of simulation data ###
########################################################################################
### Copyright 2017-2022 Jannik Luboeinski, Andre... |
455f2e8b933e7f3771ce69e8edb86bb453238f607fe233a3ea2381b1ce1692aa | Python | 8,413 | 188 | """Synthetic ground truth for spike sorting on a low-density MEA.
Real culture recordings have no ground truth, and on a single electrode two
sorters can split the same spikes differently with nothing to say which is
right (see ``python/SPIKE_SORTING_PLAN.md`` §3.3). This module makes a
recording where the answer is k... |
221803bc4ce298e7480c0c7bfb8e91519d06acb682d127f918e4a26c92f1e664 | Python | 8,414 | 274 | """Brain-Score wrapper for DeepEISNN EI-SNN CIFAR10 ResNet18."""
from __future__ import annotations
import functools
import json
import sys
from collections import OrderedDict
from pathlib import Path
from typing import Any, Iterable
import numpy as np
if not hasattr(np, "int"):
np.int = np.int32
import torch
... |
5c3a271fa3c89d824075d3288fb506c54db353dee556550a94cd36f9feccb1e7 | Python | 8,415 | 199 | import logging
import numpy as np
from typing import List, Tuple
from brainscore_core.supported_data_standards.brainio.assemblies import merge_data_arrays, walk_coords, DataAssembly
from brainscore_vision.model_helpers.utils import fullname
from brainscore_vision.model_interface import BrainModel
def iterable_to_lis... |
8a904c24256398330649e85280df54ba9307ce02190a030b8a8406874cc9530a | Python | 8,415 | 194 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Generate multi-shell gradient sampling with various processing options. Helps
accelerate gradients, optimize duty cycle and avoid artefacts.
Multi-shell gradient sampling is generated as in [1]. The bvecs are then
flipped to maximize spread for eddy current correction... |
8e13a7193945e2226fc17747ae2b17e80e7dee20d55dd1ea66a1b9c201aabfa5 | Python | 8,421 | 202 | # %%
import torch
from torch_geometric.nn import SAGEConv, to_hetero,GeneralConv
from torch.nn import Linear
import torch.nn.functional as F
from sklearn.metrics import roc_auc_score,average_precision_score
import numpy as np
import random
import pandas as pd
from torch_geometric.explain import Explainer
from torch_geo... |
92183cc3fc8284125c146c7f2f35697ed25a3d058f0d5cbb6b421a2ab7f6caa9 | Python | 8,421 | 197 | from .util import Partition, new_vectors, new_vectors_sparse, match_clusters, compare_clusters, weighted_jaccard_distance
from .utilgpu import weighted_jaccard_cpu_fast, weighted_jaccard_gpu_csr, is_cuda_available
import numpy as np
from scipy.sparse import csr_matrix, coo_matrix
from scipy.sparse.linalg import norm
fr... |
b89700a0b5f255a924752852bfa8c020acf89735c52b8062fc4a6ab03a3940ef | Python | 8,421 | 266 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Author: Yong Bai, yong.bai@hotmail.com
@License: (C) Copyright 2013-2022.
@File: _svgplot.py
@Desc:
"""
import scanpy as sc
from scipy.sparse import issparse
import matplotlib.pyplot as plt
import matplotlib.transforms as mtransforms
from ._utils import _panel_grid... |
89284910159e010added38636bdabc97f55e991b20cef69c5b8dd817f867091d | Python | 8,425 | 228 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
T-test-based Feature Selection Pipeline
This module provides a function to identify connections (features) associated with
a binary target variable using independent t-test.
The pipeline:
1. Performs independent t-test between two groups (e.g., case vs. control)
2. A... |
90e9e928be150c8c3b9357eb5aec3d9bd746ae8e1b590abc3a8ad0838e77372b | Python | 8,426 | 208 | import torch
import torch.nn as nn
import torch.nn.functional as func
class Attention(nn.Module):
def __init__(self, hidden_dim):
super().__init__()
self.fc = nn.Linear(hidden_dim, hidden_dim)
self.weight_vector = nn.Parameter(torch.randn(hidden_dim, 1))
def forward(self, x):
... |
4364bc8122588f8698fac54f7d27cbb2fc6e7c7002911fb21095415744fde859 | Python | 8,427 | 202 | from typing import Literal, get_args
import numpy as np
import polars as pl
from matplotlib_venn import venn2
from argclz import AbstractParser, as_argument, argument
from argclz.dispatch import Dispatch, dispatch
from neuralib.atlas.ccf.dataframe import ROIS_NORM_TYPE
from neuralib.plot import plot_figure
from neura... |
ca91f4f7642c3f3cf569a9d9ee723bcf3c3a7885ae2a735c2de2883f547583b6 | Python | 8,428 | 245 | #该程序的作用是一个完整的Python脚本,用于对胰腺炎训练集数据进行LASSO回归分析的lambda最优参数求解
#并画出LASSO交叉验证AUC曲线图和LASSO系数变化趋势图
# 运行得出最优lambda值为0.000838
#程序编写于2025年8月27日,编写者:龙诗科
import pandas as pd
import numpy as np
from sklearn.linear_model import LassoCV, Lasso
from sklearn.model_selection import KFold
from sklearn.metrics import roc_auc_score
... |
feb61161f6d2fcbb328e0dbad78e2a391ef32fcf5971243b2f4d06eb6a242fd0 | Python | 8,429 | 202 | from torch_geometric.data import InMemoryDataset
import pandas as pd
import shutil, os
import os.path as osp
import torch
import numpy as np
from ogb.utils.url import decide_download, download_url, extract_zip
from ogb.io.read_graph_pyg import read_graph_pyg
class PygGraphPropPredDataset(InMemoryDataset):
def __i... |
c3fabd6b33372eb33a6ee436c0ba3ad72cb0184265e226ba889d3f5ce426a262 | Python | 8,433 | 230 | from collections.abc import Callable
from pathlib import Path
from typing import TYPE_CHECKING, cast
import torch
from lightning.fabric.wrappers import _capture_compile_kwargs
from torch import nn
from torch.nn import functional as F
from eir.experiment_io.input_object_io_modules.sequence_input_io import (
load_s... |
11a4bdaf9aaaac3a3803722e82d48de07c39b0a6a9e1560e497543f395c11798 | Python | 8,437 | 260 | from data_utils import get_image_T, write_to_json, filter_and_crop
from deepreg.predict import unwrapped_predict
from tqdm import tqdm
import deepreg.model.layer as layer
import h5py
import json
import numpy as np
import os
import tensorflow as tf
def set_GPU(device: int):
gpus = tf.config.list_physical_devices('... |
9e3ecef4eb89328d49e783db627784412ec2df9f4baf46c7b9131d080d9c1256 | Python | 8,437 | 206 | # 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, ... |
178adb3d311ecabe0c6b55ad7948b0b15912e093be05cece516a78202bab686b | Python | 8,438 | 207 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Script to create a surface with marching cube from a mask or a label image.
The surface will be readable with software like MI-Brain.
Example : use wmparc.a2009s.nii.gz with some aseg.stats indices
scil_surface_create out_surface.vtk \\
--in_labels s1a1/mask/S1-A1... |
4e86f4a104297a5aa3e48fdeff3218cab8518ce14093bb998c36ecbb74332387 | Python | 8,438 | 263 | """
Support for the `MAF`_ multiple sequence alignment format used by `multiz`_.
.. _MAF: http://genome.ucsc.edu/FAQ/FAQformat.html#format5
.. _multiz: http://www.bx.psu.edu/miller_lab/
"""
from io import (
StringIO,
TextIOWrapper,
)
from bx import interval_index_file
from bx.align import (
Alignment,
... |
0d61a7cc98d6504b6d32629d7c033893e298e74b8fbbd4dda5d17521816a399e | Python | 8,439 | 213 | import pytest
import torch
import SimpleITK as sitk
import numpy as np
from fireants.io.image import Image, BatchedImages, FakeBatchedImages, concat
from fireants.registration.distributed import parallel_state
import os
## needs to be run with `torchrun --nproc_per_node=1 test_image_io.py`
@pytest.fixture
def sample_... |
987e6220b8ff016e0de6a1a6a66394053a61c5f22b3220cb51abb5c8b0981b25 | Python | 8,439 | 204 | 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,somethreshold=999e6):
if datatype=='none':
alldatavalues=datas
#pri... |
a7891ac3b7f9cb53166100975c608f136ce8ea2acf7fc019a4a4b6777c862915 | Python | 8,439 | 223 | import shapely
import numpy as np
import pandas as pd
import argschema as ags
from skeleton_keys.layer_alignment import (
setup_interpolator_without_nan,
path_dist_from_node,
)
from neuron_morphology.swc_io import morphology_from_swc, morphology_to_swc
from neuron_morphology.transforms.pia_wm_streamlines.calcul... |
4df94fdc9a5dcb55ed3f69693a6f545c735cd4f5face0327d3038b82d8c2688e | Python | 8,441 | 223 | import sys
import yaml
import os
import numpy as np
import pandas as pd
import matplotlib as mpl
from matplotlib import pyplot as plt
pathpath,myrun = sys.argv[1:]
with open(pathpath) as yfile: pathdict = yaml.safe_load(yfile)
savedir_output = os.path.join(pathdict['figdir_root'],'SOMruns',myrun,'%s__countstats'%myr... |
0e212a439cb86c1ba18b48728d863a68c36a138e9e429d2eef4cc3cfa98cb161 | Python | 8,443 | 270 | #!/usr/bin/env python3
"""
Fig4Sup3b_pH_dFF_AllSensors.py
Plots ΔF/F vs pH for all sensors overlayed on a single plot.
ΔF/F = (F_sat - F_apo) / F_apo
Shows how GABA response magnitude changes with pH.
Usage:
python Fig4Sup3b_pH_dFF_AllSensors.py
python Fig4Sup3b_pH_dFF_AllSensors.py --file "01_raw_tecan_data.... |
9bd360481a8f693e0b4054a229b5a5bb60efc38bb92e004de138009eba98cd94 | Python | 8,445 | 243 | # -*- coding: utf-8 -*-
# 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 torch
from torch import Tensor, nn
import math
from typing import Tuple, Type
from .commo... |
e2e256a83f7c64c9dc07525d76fc2b09dc143fa232011e66c948254fcf7c2108 | Python | 8,446 | 261 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import csv
import json
import os
import random
import sys
from itertools import product
NAME = "issues"
def read_rules(name):
rules = []
with open(os.path.join(sys.argv[1], f"{name}.csv")) as f:
reader = csv.DictReader(f)
f... |
63175101c0a4e9cc73cb48236cb12e1ae1697355c1cc0e16cbe6779ee2d73c7d | Python | 8,448 | 195 | import os
import re
def rename_bids_file(original_filename, entities, suffix, extension):
"""
Rename file to comply with BIDS requirements, automatically extract all entities, and allow overriding existing entities and suffix.
:param original_filename: str, original filename (e.g., sub-AF1000077_ses-01_T1w... |
48e2c2cca823169f1744d564a584e593f11c0755110dcda94e1a295e317e2b10 | Python | 8,450 | 198 | from labdatatools.analysis import *
import argparse
class AnalysisSuite2p(BaseAnalysisPlugin):
def __init__(self,subject,
session = None,
datatypes = [''],
includes = [''],
excludes = default_excludes,
bwlimit = None,
... |
5437b874840198c1915b658da4295f52acb1467efe26e5a41d0e558bbce0504b | Python | 8,450 | 240 | """model.py."""
import jax.numpy as jnp
import numpy as np
import numpy.typing as npt
import numpyro
import numpyro.distributions as dist
from jax import Array
# ruff: noqa: N803, N806, PLR0913, PLR0914, PLR0917, PLR2004
GP_INPUT_DIMENSIONS = 3
def get_default_priors() -> dict[str, dist.Distribution]:
"""Get d... |
e9cb00ad2c16de06d25376ae448f5293c3104101bc8a1f69a731aba5867cfde1 | Python | 8,451 | 262 | # -*- coding: utf-8 -*-
#
# MyGene.py documentation build configuration file, created by
# sphinx-quickstart on Wed Jan 8 09:57:08 2014.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# A... |
82b71f53107e44637b43327f8d0dd647f37b833d7731a19784166265a14c33cd | Python | 8,453 | 179 | #!/usr/bin/env python
import glob
import os.path
import re
import sys
warnings = 0
def report(rule, location, description):
global warnings
warnings += 1
print(f'{warnings:3}. {location}: {description} [{rule}]')
def check_structure():
expected_sections = [
'Template parameters',
... |
6bc241cb812f3874edeacbbfa793b6a7166c09607aad9ab01baa3ae1ef0e4a13 | Python | 8,455 | 228 | import os
import numpy as np
from brainscore_vision.model_helpers.brain_transformation.temporal import assembly_time_align
def concat_with_nan_padding(arr_list, axis=0, dtype=np.float16):
# Get shapes of all arrays
shapes = [np.array(arr.shape) for arr in arr_list]
max_shape = np.max(shapes, axis=0)
... |
daf34147a30be416d2d70ae5784baa99567ba511af3da659c27dab58f055f8bb | Python | 8,457 | 260 | """ MLP module w/ dropout and configurable activation layer
Hacked together by / Copyright 2020 Ross Wightman
"""
from functools import partial
from torch import nn as nn
from .grn import GlobalResponseNorm
from .helpers import to_2tuple
class Mlp(nn.Module):
""" MLP as used in Vision Transformer, MLP-Mixer an... |
3088ca7ee0f30e72b306d911736479085bbe00661c699f42daae61c000dae56b | Python | 8,458 | 254 | """Use UNI2-h to extract latent features from whole slide images."""
from __future__ import annotations
import argparse
from pathlib import Path
from typing import Callable, List, Optional, Sequence, Tuple, Union
import h5py
import numpy as np
import openslide
import torch
from PIL import Image
from torch.utils.data ... |
3ec1ee94f4ec3d9618c693a94330107a5397cb7a15bafc40f49dd6597bda4941 | Python | 8,461 | 194 | # /------------------------------------------------------------------------------+
# | 19-JUL-2022 |
# | Copyright (c) Bone Imaging Laboratory |
# | All rights reserved ... |
f8dfdadee7b475b58c918bd8b3b8fdc38aa07beec3f4c5e7fa44e24f4c3b9bed | Python | 8,461 | 192 | """How good is a match, and how good is a chain?
Inspired by Bombcell's per-unit quality metrics, with one important difference
established by measurement rather than assumed.
**There is no useful composite score.** Combining the fingerprint with activity
agreement (event rate, inter-event interval, population coupli... |
862f470918bc9a9e747764baee21ab80c0bf5d80bd0efc334a18d8cdc84a76cd | Python | 8,462 | 238 | import sys
import yaml
import os
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
from scipy.stats import scoreatpercentile as sap
pathpath,myrun,ncluststr,cmethod = sys.argv[1:]
ncl = int(ncluststr)
with open(pathpath) as yfile: pathdict = yaml.safe_load(yfile)
rundict_path = pathdict[... |
2102d7d8c74b606fa19cd845b084df2dd5c5063a5afac57bd6dded047da6c332 | Python | 8,463 | 212 | import numpy as np
import pytest
import nelpy as nel
class TestGaussianFilterCoverage:
"""Test various code paths in gaussian_filter function to increase coverage."""
def test_gaussian_filter_analog_signal_array(self):
"""Test gaussian_filter with AnalogSignalArray."""
# Create a simple ASA
... |
4affef3981a3b73bb757eaeff2d49c16d3f6651efa898ea97928be43cac896ea | Python | 8,464 | 278 | #!/usr/bin/env python3
import sys, os, re
import collections
ORIG_TRANSDECODER_FLAG = False
def main():
import argparse
parser = argparse.ArgumentParser(description="transdecoder orf selection algorithm", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("--long_orfs_cds... |
444b4dad80243aa7edcc446e3e790f6b9716f17686a0239737bb124bd90050de | Python | 8,467 | 252 | import torch
from torch import nn
import numpy as np
class MultiTaskSplitterFunction(torch.autograd.Function):
@staticmethod
def forward(ctx, z, num_copies: int, symmetric: bool):
ctx.save_for_backward(torch.tensor(symmetric))
output_list = [z for _ in range(num_copies)]
return tuple(o... |
4247e0a2dc825bb57fe94fd8e7b407bcca696ee5ad1d04cfb146135e4ef70734 | Python | 8,469 | 238 |
import tensorflow as tf
import csv
import numpy as np
import SimpleITK as sitk
import matplotlib.pyplot as plt
from numpy import argmax
import pandas as pd
import tensorflow.keras.backend as K
from tensorflow.keras import initializers
from tensorflow.keras.callbacks import Callback
from tensorflow.keras.layers import ... |
f5603bf8edf9b28709d7c4df813d24b49552e66e203c8f0b698835fa5a1447af | Python | 8,471 | 250 | # Copyright (C) 2019-2022 Intel Corporation
# Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import functools
import re
import shutil
from django.conf import settings
from django.db import transaction
from django.db.models.signals import m2m_changed, post_delete, post_save, pre_delete, pre_save
fro... |
3e5651058a1e5ff8c7b6c383c0a8ea0403c3784bd450cfadd1fac372bfa28823 | Python | 8,476 | 240 | """EpochArray tests"""
import numpy as np
import nelpy as nel
def _reference_merge(data, *, gap=0.0, overlap=0.0):
data = np.asarray(data, dtype=float)
if data.size == 0:
return np.empty((0, 2))
data = data[np.argsort(data[:, 0])]
merged = [data[0].copy()]
covered_stop = data[0, 1]
... |
d80726584f2d63e517f7b0663cf6ef618e1112540fdb0773f77d68eb288a8c0c | Python | 8,476 | 223 | import numpy as np
import pandas as pd
import torch
from fuse.data import PipelineDefault, OpToTensor
from fuse.data.datasets.caching.samples_cacher import SamplesCacher
from fuse.data.datasets.dataset_default import DatasetDefault
from fuse.data.ops.op_base import OpBase
from fuse.data.ops.ops_aug_common import OpSamp... |
406e7026b52df889da296cf06910c7e02d120fd4ab91f283bc81e5a5d18d92ec | Python | 8,477 | 147 | import os
from copy import deepcopy
from typing import Union, List
import numpy as np
import torch
from acvl_utils.cropping_and_padding.bounding_boxes import bounding_box_to_slice
from batchgenerators.utilities.file_and_folder_operations import load_json, isfile, save_pickle
from nnunetv2.configuration import default... |
997ea352f5dd5c1a8da2bfa2020d43420a7af2ec3208ed59769cf5116bc1410a | Python | 8,480 | 179 | import src.data_generator as adg
import src.utils
import glob
import cmat
import pandas as pd
import pickle
import argparse
import os
import src.config
def train(config, dataset_path=None):
# Load dataset path
if dataset_path is None:
dataset_path = config.TRAIN_DATA
if not os.path.exists(dataset_p... |
37263734af24d8e43fbca768c7317de275206ff36bd3fa69f0c678136aa078c2 | Python | 8,481 | 262 | from unittest.mock import MagicMock, patch, mock_open
from dynamont.segmentation.segment import get_raw
from collections import OrderedDict
from unittest.mock import MagicMock, patch
class TestSegment:
def setup_method(self):
import dynamont.segmentation.segment as segment
segment.RAW_CACHE = O... |
7769e9df0ded50755f2be02cdca70b939f8556068405bbbccb61d6b48be3c1dd | Python | 8,482 | 167 | # noinspection PyUnresolvedReferences
import math
# noinspection PyUnresolvedReferences
import pathlib
# noinspection PyUnresolvedReferences
from neuron import h
# noinspection PyUnresolvedReferences
import neuron_interface.neurosim
from .cell_modification_parameters.cell_modification_parameters import (
CellMod... |
5043726daf37294169f7ef4a89a9f8ecd58cf1c2c30cc9188e960147f503ab45 | Python | 8,484 | 232 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import csv
import os
import uuid
from datetime import datetime, timedelta, timezone
import clickhouse_connect
from dateutil import parser
from django.conf import settings
from rest_framework import serializers, status
from rest_framework.response im... |
d41838605fd677f5e706be6e60ceeb8ca9f7eb98d971278869f57c570cb6cfa3 | Python | 8,487 | 150 | """Build audited core design and conservatively pooled counts; no model fitting."""
import json
from pathlib import Path
import numpy as np
import pandas as pd
from src.acquisition.download import ROOT, sha256
from src.audit.inventory import align_samples, require_unique, verify_manifest
CORE_CONDITIONS = {'Ctrl': ... |
1171ec67cda4310f5a90740c6d9518f51ae376c41973e068e733f1b7d29ad766 | Python | 8,488 | 222 | from qiskit import QuantumCircuit
from qiskit.quantum_info import Operator
import numpy as np
class MyNdarray:
def __init__(self, arr:np.ndarray):
self.arr = arr
# we can use A^B instead of np.kron(A,B)
def __xor__(self, other):
return MyNdarray(np.kron(self.arr, other.arr))
d... |
84773c8302b888b954f560b5f8cc16caf2698319b4615be0c0b386fcd1dcc4ac | Python | 8,491 | 251 | """
This script loads trained RNN snapshots, computes the Singular Value Decomposition (SVD)
of the recurrent weight matrix for each model, plots the cumulative variance explained,
and writes a .txt report with the range, mean, and 95% confidence interval of the
effective dimensionality.
It also includes a function to... |
bb751894ca15f74589becb09042b90f105f57f8dc05c6782eaa05f3768079306 | Python | 8,491 | 167 | # noinspection PyUnresolvedReferences
import math
# noinspection PyUnresolvedReferences
import pathlib
# noinspection PyUnresolvedReferences
from neuron import h
# noinspection PyUnresolvedReferences
import neuron_interface.neurosim
from .cell_modification_parameters.cell_modification_parameters import (
CellMod... |
bfd920c2877e79d9ab5ccffe571ad6a33f61005d8b9fcd6e9cee7d1ebbf9cfab | Python | 8,491 | 167 | # noinspection PyUnresolvedReferences
import math
# noinspection PyUnresolvedReferences
import pathlib
# noinspection PyUnresolvedReferences
from neuron import h
# noinspection PyUnresolvedReferences
import neuron_interface.neurosim
from .cell_modification_parameters.cell_modification_parameters import (
CellMod... |
678f0bb07346b627462cd2c6d5a8184dc9816f222482f67bd793b640c68c86f0 | Python | 8,493 | 182 |
import os
from time import time
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
import torch
import torch.backends.cudnn as cudnn
#from torch.utils.data import DataLoader
from monai.data import DataLoader
from dataset.kidney_dataset import KidneyData
#from tqdm import tqdm
#from lo... |
fffab5f28dfc3dce675a66e45d024b75db673943bc33ac8ebce8ba1479e82a23 | Python | 8,493 | 170 | from .regression_curve_fitter import RegressionCurveFitter
from sklearn.base import BaseEstimator as SKLearnBaseEstimator
from typing import Any, Optional
import pandas as pd
from copy import deepcopy
from .survival_utils import canonize_dtypes_and_names, safe_join
from .base_survival import SurvivalBase
class Standa... |
ecd0cf09f80133e4be5de40721c390baed5e7b0ccca7c252e0e447b84b194054 | Python | 8,494 | 209 | import numpy as np
from scipy.spatial.distance import cosine
from scpca.pca import dPCA, scPCA
from scpca.train import DEFAULT, TEST
from scpca.utils.data import _get_model_design
def is_aligned(a, b, atol=0.001):
"""
Checks if the vector is aligned, i.e. it has the same direction (cosine distance == 0)
... |
0eff0d855faac9f61e7245abf0c53555e734af1d3c1cbe330be0f82062c0f467 | Python | 8,496 | 252 | import logging
from time import time
import immlib
import nibabel as nib
import numpy as np
from trx.trx_file_memmap import TrxFile
import AFQ.tractography.tractography as aft
from AFQ.definitions.image import ScalarImage
from AFQ.definitions.utils import Definition
from AFQ.tasks.decorators import as_file
from AFQ.t... |
3306f126a9103e281e39ae80702e33d2d96cc850ec42fa26977d0205c8834b7f | Python | 8,498 | 218 | """Globus Compute execution backend.
Wraps the `Globus Compute SDK <https://globus-compute.readthedocs.io/>`_
to conform to the :class:`ExecutionBackend` interface. Python tasks are
dispatched via :meth:`Executor.submit` and shell tasks via
:class:`ShellFunction`.
Unlike the Parsl and EnsembleLauncher backends, Glob... |
d42c1989d2196d2c816953e07e882a76b3003a859c8a7d9db5d9ef374ad57ed3 | Python | 8,498 | 196 | import os.path
import shutil
import unittest
import tests.base_test
import tests.output_parser as output_parser
import tests.test_config
import tests.util
class Test(tests.base_test.BaseTest):
def setUp(self):
super().setUp()
self._test_base_dir = tests.test_config.TEST_BASE_DIR
self._te... |
0d626ce7dde73fb022847ce9b1dfd4b910b636376949637280463d2c16283487 | Python | 8,501 | 202 | # %%
import os
import glob
import random
import monai
from os import makedirs
from os.path import join
from tqdm import tqdm
from copy import deepcopy
from time import time
import numpy as np
import torch
from torch.utils.data import Dataset, DataLoader
from datetime import datetime
import cv2
import argparse
from mat... |
c7cbdab9591a2bd1f52c43fbd28c411dd491eb34eef1a772bc820f3fd81f3f07 | Python | 8,501 | 223 | # Copyright (C) 2022 Intel Corporation
# Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
from allauth.account import app_settings as allauth_settings
from allauth.account.adapter import get_adapter
from allauth.account.utils import filter_users_by_email, setup_user_email
from dj_rest_auth.registrat... |
1e851de52e7ef980cd405efde423ae301d0412cd9a7ef937101caefb09df9400 | Python | 8,502 | 229 | #!/usr/bin/python
# -*- coding: latin-1 -*-
# =============================================================================================
# Librairies importation
import numpy as np
import nrrd
import atlalign as atl
from atlalign.non_ml.intensity import antspy_registration
from atlannot.ants import register, tra... |
2d001cd6891c9e8661e55706499bfecd25de025bf901829bdc8ac0a1c3aa814e | Python | 8,503 | 255 | """
This script computes the cross-validation results for the switch evidence dim
using leave-one-out cross validation and an additional null model where the
n_pre_switch_lvl is replaced with consecutive sequences of 3 trials unrelated
to switches.
"""
import sys
import os
sys.path.insert(0, os.path.dirname(os.path.d... |
bdc0a4043ac4d1f28ced255eb4bbc52c3163a1b0d491d8bc4a043c5e46b218d5 | Python | 8,503 | 227 | """
Predict on validation set and perform fusion experiments
Uses the same random seed and split as training
"""
import os
import argparse
import torch
import torch.nn as nn
import numpy as np
import pandas as pd
from torch.utils.data import DataLoader, Subset
from data.dataset import MRIDataset
from models.resnet3d im... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.