sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
86786751072b6c35138356cd70837afb9246d4f5b3ecb0a36c87a1599bcaec6e | Python | 8,232 | 318 | # cec2017.basic
# Author: Duncan Tilley
# Basic function definitions
from typing import Optional
import numpy as np
def bent_cigar(x: np.ndarray) -> np.ndarray:
sm = np.sum(x[:, 1:] * x[:, 1:], axis=1)
sm = sm * 10e6
return x[:, 0]*x[:, 0] + sm
def sum_diff_pow(x: np.ndarray) -> np.ndarray:
i = np.... |
963f260743d9093ba2ed8482a4402dc5d983ba67e2dd5ef58050fe5b17df7724 | Python | 8,232 | 175 | import mne
import pickle
import numpy as np
import matplotlib
from matplotlib import pyplot as plt
from matplotlib import rc
from matplotlib import cm
from mne.channels.layout import (_find_topomap_coords, find_layout, _pair_grad_sensors, _merge_ch_data)
from scipy.ndimage import uniform_filter1d
from scipy.signal i... |
1ca7f7eebdba882a691b6ffb2a4192475bb49fbbbcfa7e6b755a769eeb5669cb | Python | 8,234 | 193 | import os
import json
import csv
def set_tf_config():
"""
This functions sets the necessary values in the TF_CONFIG environment variable. It contains information on the
cluster architectures, i.e, which workers are allocated for the job, and the worker for the current task. This has
been ... |
37fc259dc543c1feaabdd80b334bfa80892b64b3c5364ff6dc7b67ca2eb52b28 | Python | 8,235 | 271 | #!/usr/bin/env python3
from pathlib import Path
import glob
import cmd
import configparser
import distutils
import os
import sys
import subprocess
import shutil
import json
import fnmatch
import signal
from run import run as runtest
from printdiff import print_diffs
class colors:
GREEN = '\033[32;1m'
RED = '\033[3... |
8b9903b4ed0161ad71311b958a06b58a6f43b894067807b6155af620b7810221 | Python | 8,235 | 220 | import os.path
import warnings
import numpy as np
import skimage.io as io
import torch
import torch.nn.functional as F
from bism.models import get_constructor
from bism.models.spatial_embedding import SpatialEmbedding
from torch import Tensor
from torch.cuda.amp import autocast
from tqdm import tqdm
import skoots.lib... |
c8d46e6bd02def8733f2497b29ec629b3e5e9648411d45e6e84f87cbb6c3191d | Python | 8,237 | 235 | import jax
import jax.numpy as jnp
import matplotlib.pyplot as plt
import glob
import sys
import os
import re
import json
plt.rcParams["font.sans-serif"] = ["DejaVu Sans"] # Best available
plt.rcParams["font.family"] = "sans-serif"
plt.rcParams.update({
"font.size": 10,
"axes.titlesize": 10,
"axes.l... |
13d05ff3c784499e37514290471a396f112bb76af6477c420313dd0b826f7791 | Python | 8,239 | 219 | #############################################################################
# Copyright (C) 2020-2026 MEmilio
#
# Authors:
#
# 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 License.
# You may... |
040513405508fdc75486a028a080383ee1b4a1a543ae42739ada942e8b5bb7a0 | Python | 8,240 | 212 | import os
import glob
import re
import numpy as np
from PIL import Image, ImageDraw, ImageFont
from tqdm import tqdm
def create_training_gifs(results_dir):
"""
Create GIFs from training visualizations.
Parameters:
- results_dir: Directory containing the visualization images
Returns:
... |
a6c4315b322090a12646a77af3fe1d0da8782e7a2dd916ef26b4ff077a2d2e47 | Python | 8,241 | 248 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import csv
import json
import os
import random
import sys
from itertools import product
random.seed(42)
NAME = "tasks"
def read_rules(name):
rules = []
with open(os.path.join(sys.argv[1], f"{name}.csv")) as f:
reader = csv.DictRea... |
d85160c1bdf86f1e3759ad422c9ed07124ab4d5dbfa7d8d5a8875975dc9d96d5 | Python | 8,241 | 232 | from __future__ import annotations
import re
from pathlib import Path
from typing import Dict, List, Optional, Tuple, Union
import pandas as pd
_FLOAT_RE = r"[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?"
# -----------------------------------------------------------------------------
# Table header detection: support ... |
73bf08eb7921111b871eea468f7aaadbf43493b324290f884a7707c85e6f00cd | Python | 8,243 | 208 | from nipype.interfaces import spm
from nipype.interfaces import matlab
from nipype.interfaces import cat12
from nipype.interfaces.freesurfer import ApplyVolTransform, ApplyMask
import nibabel as nib
import numpy as np
import os
import shutil
import subprocess
spm_path = '/home/degutis/repos/spm'
def configure_spm():
... |
d66bfbff0281065a703685ff47d20748cb69e5b632b66ac4cbcbd9b4d372020e | Python | 8,243 | 165 | import logging
import numpy as np
from zigzag.classes.mapping.spatial.spatial_mapping import SpatialMapping
from zigzag.classes.stages.Stage import Stage
logger = logging.getLogger(__name__)
class SpatialMappingConversionStage(Stage):
"""
Pipeline stage that converts the spatial mapping from a
user-pro... |
ff6d99ce5a13fd2e39b7983714aedf02887f39bad5fb58ef80de359521aa2ffe | Python | 8,246 | 272 | # 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... |
de712c230e7be925e569483912c9183ab99a7e640902d14403744db86997de18 | Python | 8,247 | 153 | from train_gtex import *
def load_tpm_datasets(config,train_genes,valid_genes,test_genes):
"""
Overwrite to use Log2TPM + 2 expression data, as opposed to the GTEx expression data normalized for eQTL studies, which are transformed to appear standard normal.
TPM data contains information about avearge expr... |
a94bc1ef243188504078ee8bc7b65e79b44958160fd8f552860be8273704dea5 | Python | 8,248 | 197 | """Stimulation activity analysis — electrode-level response metrics.
Ports the ``StimActivity_NodeLevel.csv``-producing core of
``stimActivityAnalysis.m`` (origin/main) plus ``saveEphysStatsStim.m``.
Only the deterministic, CSV-producing path is here (gaussian-smoothed
individual-electrode PSTH, d′, z-score, AUC corr... |
d5cb525fc77367fe3680bb748c56d1abd6e594b724c0fb2f3719e65435bfce8d | Python | 8,251 | 180 | # -*- coding: utf-8 -*-
"""
Created on Wed Dec 4 20:04:12 2019
@author: Yoshi
"""
import os
import shutil
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from PIL import ImageColor
def cell_grapher(path,data,cell_flags,correlation_coefficients,areas_under_curves,framerate_information,key,fr... |
60baeed917e0a62d6f0d529627ec109afb1863c1924c986d3d159e8c1794977c | Python | 8,252 | 276 | from collections.abc import Iterable, Sequence
from dataclasses import dataclass
from typing import (
TYPE_CHECKING,
Any,
Literal,
)
import torch
from sklearn.preprocessing import LabelEncoder, StandardScaler
from torch import nn
if TYPE_CHECKING:
pass
# Aliases
al_tabular_input = dict[str, list[str]... |
c8ddec2d0ca1f1723a732005fdcd1dca455069e3aeb298b37ed74443e4c0f609 | Python | 8,253 | 240 | import math
import numpy as np
import obspy
from obspy import ObsPyException
from obspy.clients.fdsn import Client as FDSNClient
from obspy.clients.fdsn.client import FDSNException, FDSNNoDataException
from obspy.io.mseed import ObsPyMSEEDError
import seisbench
def trace_has_spikes(data, factor=25, quantile=0.975):... |
de843bf759b229c9cdecccfb58817ca87b49deede86c331223b8e686c5b0dcc8 | Python | 8,254 | 249 |
"""
Section 3 -> specific figures of components and cell types method relation
"""
import scanpy as sc
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import matplotlib as mpl
import os
import warnings; warnings.simplefilter('ignore')
import anndata
from sci... |
80059f40a33a1d7aef828dad287bfac4bcd0ef57545d4883c8cda4606b0e86e2 | Python | 8,255 | 209 | import os.path
import unittest
import tests.base_test
import tests.output_parser as output_parser
import tests.test_config
import tests.util
class RetainedIntronNovelBaseTest(tests.base_test.BaseTest):
def setUp(self):
super().setUp()
self._test_base_dir = tests.test_config.TEST_BASE_DIR
... |
7b7380419b65653dfc6655f7a16c9d426db2827035d6014e63a2765b7cbfa9e8 | Python | 8,258 | 259 | from __future__ import annotations
import typing
from dataclasses import dataclass
from typing import Final
import numpy as np
from numpy.typing import ArrayLike
from numpy.typing import NDArray
from .._shape import MIN_POLYGON_POINT_COUNT
from .._shape import Shape
from ._geometry import Circle
from ._geometry impo... |
0791583e4e1283838ce73063d582b84fcc7ac0eab7cf98e3b5636c52b84dc2d7 | Python | 8,259 | 192 | import sys
import importlib
import itertools
import pandas as pd
import pingouin as pg
import numpy as np
import matplotlib.pylab as plt
plt.rcParams['font.family'] = 'Helvetica'
plt.rcParams['text.usetex'] = True
plt.rcParams['font.size'] = 20
plt.rcParams['text.latex.preamble'] = "\\usepackage{sfmath}"
import warnin... |
5000ff8b6e7fabc2e1c25a3091b64ce8e07d6c6badd9507d389c41725d8a7d6a | Python | 8,259 | 198 | # -*- coding: utf-8 -*-
"""
Created on Thu May 21 19:19:01 2020
读取数据并对数据做预处理
统计出训练数据中出现频次最多的5k个单词,用这出现最多的5k个单词创建词表(词向量)
对于测试数据,直接用训练数据构建的词表
@author:
"""
import os
import torch
import torch.nn as nn
from torch.autograd import Variable
import csv
import pandas as pd
import numpy as np
import sklearn
glove_path = r"/dat... |
18eeace34acaccab2ca816629611344b26d70cb8db412a1997a965700e7b4f6d | Python | 8,261 | 261 | from collections.abc import Sequence
from copy import deepcopy
from typing import TYPE_CHECKING, Any
import numpy as np
import pytest
from scipy.spatial.distance import cosine
from sklearn.metrics import mean_squared_error
from eir import train
from eir.train_utils.utils import seed_everything
from eir.utils.logging ... |
94c8ff1765e201b23980e9e566d57bafaa29b86b7bc1b080a3d6958c1d294480 | Python | 8,262 | 143 | # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'hal4000.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_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.... |
446f249f902eb75649bd2446b99ff24aa00b60acd49fea8476f0c0fd7339c081 | Python | 8,264 | 195 | # -*- coding: utf-8 -*-
"""
Created on Thu May 21 19:19:01 2020
读取数据并对数据做预处理
统计出训练数据中出现频次最多的5k个单词,用这出现最多的5k个单词创建词表(词向量)
对于测试数据,直接用训练数据构建的词表
@author:
"""
import os
import torch
import torch.nn as nn
from torch.autograd import Variable
import csv
import pandas as pd
import numpy as np
glove_path = r"/data2/whr/zqy/glove... |
daba298d830544291fce443584686d770f991da3b5c2473bd3763e714a0d89b6 | Python | 8,270 | 195 | from sklearn import metrics
import numpy as np
import pandas as pd
import seaborn as sns
from .stats import *
from .scn_train import *
import matplotlib
import matplotlib.pyplot as plt
def divide_sampTab(sampTab, prop, dLevel="cell_ontology_class"):
cts = set(sampTab[dLevel])
trainingids = np.empt... |
5ca7f436c927e4232c1b62283dd950696d2908b5afe7062aad615048d3ba0550 | Python | 8,271 | 242 | #!/usr/bin/env python3
"""
=============================================================================
Austin Dibble
University of Glasgow
2026
scripts/get_test_data.py
Utility to fetch test data for debugging NeuroFM inference.
If using the template mode, this script requires templateflow.
To avoid dependency con... |
69f472ef1d14689189e56b1f6cc4fc787e1c8426184c7adc09f60a370cb18b67 | Python | 8,271 | 219 | import numpy as np
import matplotlib.pyplot as plt
import yaml
import sys
import os
import h5py
import matplotlib as mpl
import csv
import pandas as pd
from sklearn.metrics.pairwise import cosine_similarity
from scipy.spatial.distance import pdist
import scipy.cluster.hierarchy as hac
from scipy import stats
pathpath... |
03409718d147535a8fc0abec62185fb9d28d82a3e00134a70fe9a56398d9d745 | Python | 8,273 | 202 | """UL-DD dataset access layer.
Layout documented in Bodaghi et al., Scientific Data 13:506 (2026),
"A multimodal drowsiness dataset using video, biometric, and behavioral data",
Zenodo record 17978727 (restricted access).
<root>/
CSV_Files/<SUBJ>/<SESS>/<SUBJ>_<SIG>_<SESS>.csv
Extracted_Features/<... |
80c2727e0c53b6915928731e308f78ffe1d281c186b80f45844df18cd6fdee1c | Python | 8,276 | 202 | import pfp_api_client
from pfp_api_client.pfp.calculators.ase_calculator import ASECalculator
from pfp_api_client.pfp.estimator import Estimator, EstimatorCalcMode, EstimatorMethodType
from ase import Atoms, Atom
from ase.io import Trajectory, write
from ase.build import bulk, surface, molecule, add_adsorbate, fcc111
... |
08db43b9a544d4650ec77368455f94cb283b13d89940f61d250084e2cdb58703 | Python | 8,277 | 215 | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import lmdb
import os
import pickle
import torch
import numpy as np
from functools import lru_cache
from unicore.data import BaseWrapperDatase... |
c92e85b9147f5755f0e0600e41caf10214aa35c8f2fc0c1e7757e08e0853759e | Python | 8,278 | 237 | import math
from collections import OrderedDict
import torch
from torch import nn
from torchvision import transforms
import torch.utils.model_zoo
import os
from torch.utils.data import Dataset, DataLoader
import pandas as pd
import numpy as np
import torch.nn.functional as F
import h5py
import random
import functools
i... |
576371199f105cbbc9b613c5dc3730104dd2f907ac1119f1da236716c3b5c4f1 | Python | 8,279 | 205 | import torch
import numpy as np
from torchvision import datasets
from torchvision.transforms import ToTensor
from torch.utils.data import DataLoader
import logging
#from sklearn.manifold import TSNE
def tsne_plotting(data, n_labels):
# Apply t-SNE to reduce the data to 2D
#data_2d = TSNE(n_components=2).fit_t... |
bc0dd8887be3dc030d4432a45674087c0d1291950d26bc41f2d9a2cc2ecaac44 | Python | 8,280 | 188 | import sys
import json
import os
import gzip
# Read config file
def read_config_file(config_path):
with open(config_path, "r") as f:
config = json.load(f)
return config
# Get number of reads in unknown.fastq
def count_unassigned_reads():
unknown_fastq_path = os.path.join(config["maindir"], "unknown.f... |
c7c1efe16e3779ab7f0cabee54c3ccc0272cdd512a8d058b8f8afffaf1cecdc2 | Python | 8,280 | 233 | # Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved
# 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 os
from threading import Thread
import numpy as np
import torch
from PIL import Image
from tqd... |
3a4e9d7215781c53efaf2f20c842e7cb182afe793a108289947c278d9c4205c1 | Python | 8,282 | 215 | """ Dataset reader for HF IterableDataset
"""
import math
import os
from itertools import repeat, chain
from typing import Optional
import torch
import torch.distributed as dist
from PIL import Image
try:
import datasets
from datasets.distributed import split_dataset_by_node
from datasets.splits import Sp... |
bfe36102fbc9952101a405d196636e9ad20c617effccfa0dcc013cc14ddcc9d6 | Python | 8,282 | 205 | import os
from mpi4py import MPI
# Get MPI rank early so we can set GPU env before importing torch
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
size = comm.Get_size()
# ---------------------------
# GPU pinning: ensure each MPI rank sees exactly one GPU
# (must run BEFORE importing torch)
# --------------------------... |
b092ab8a71c6c00fa7a0882d7a0d510f65b4eab774cec903fab5ee63edfa8256 | Python | 8,283 | 211 | from typing import Optional
import torch
from torch import Tensor
from torch.nn import Parameter
from torch_geometric.nn.aggr.fused import FusedAggregation
class BatchNorm(torch.nn.Module):
r"""Applies batch normalization over a batch of features as described in
the `"Batch Normalization: Accelerating Deep ... |
8313a62736ac2b384c57231fa8570879591c3b4f1483829c68fe99454f30bdd8 | Python | 8,284 | 276 | from collections.abc import Sequence
from functools import partial
from pathlib import Path
import pandas as pd
from docs.doc_modules.c_sequence_outputs.utils import get_content_root
from docs.doc_modules.experiments import AutoDocExperimentInfo, run_capture_and_save
from docs.doc_modules.serve_experiments_utils impo... |
95fb8bea5e08fb3747f7153922470dc08ce14c094fceec4e2889ac520e98d00d | Python | 8,285 | 200 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
import json
import shutil
import subprocess
import sys
from pathlib import Path
import pytest
from PIL import Image
from tests import CUDA_DEVICE_COUNT, CUDA_IS_AVAILABLE, MODELS, TASK_MODEL_DATA
from ultralytics.utils import ARM64, ASSETS, DATASETS... |
a709608eb0e61a4762c090104fb989c99abda3d6326f9a763eac66b105326219 | Python | 8,288 | 250 | """# napari image arithmetic widget
[napari](https://github.com/napari/napari) is a fast, interactive,
multi-dimensional image viewer for python. It uses Qt for the GUI, so it's easy
to extend napari with small, composable widgets created with `magicgui`. Here
we're going to build this simple image arithmetic widget... |
68c0145a4f6b1e9fd6b38d4139a749d331e685892f8cc3fe735b70871cd1de2c | Python | 8,289 | 220 | # %%
from pathlib import Path
import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt
from scipy.stats import pearsonr
import pingouin as pg
import numpy as _np
import bap1b.figures as figures
# %% load data
data_dir = Path(__file__).resolve().parents[1] / "data"
results_dir = Path(__file__).resolve... |
d9537cf16c4ea96ba83b0523f2d23c26b19ea2548d311cf6c20a3c5e64c883c6 | Python | 8,290 | 206 | #! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Compute Free Water maps [1] using the AMICO framework [2].
This script supports both single and multi-shell data.
----------------------------------------------------------
References:
[1] Pasternak 0, Sochen N, Gur Y, Intrator N, Assaf Y.
Free water elimination ... |
7c19780eba2ea93b442dcca31266405683a843ecd152e73129a10002aa59bd09 | Python | 8,293 | 291 | from __future__ import annotations
from typing import Final
import pytest
from PySide6 import QtGui
from PySide6 import QtWidgets
from PySide6.QtCore import Qt
from pytestqt.qtbot import QtBot
from labelme._widgets._tool_bar import ToolBar
def _user_buttons(toolbar: ToolBar, /) -> list[QtWidgets.QToolButton]:
... |
df786c5d6db9633e09bbc98a6a36229d93ab92aad48b54aa4e11bb32538e60d3 | Python | 8,294 | 226 | import copy
import warnings
from typing import Any, List, Optional
import torch
from torch import Tensor
from typing_extensions import Self
from torch_geometric.data import Data, HeteroData
from torch_geometric.typing import EdgeType, NodeType, OptTensor
from torch_geometric.utils import select
from torch_geometric.u... |
5d5725eee4205f92f2a3ab79160080f1e8cf3f925910471aac14b71b226c578b | Python | 8,295 | 282 | #!/usr/bin/env python3
import argparse
import functools
import re
import sys
from collections.abc import Callable
from dataclasses import dataclass
from pathlib import Path
from re import Match, Pattern
SUCCESS_CHAR = "\u2714"
FAIL_CHAR = "\u2716"
CVAT_VERSION_PATTERN = re.compile(
r"VERSION\s*=\s*\((\d+),\s*(\d... |
7e06cd6ca133a21037fad3bdd7f6aa6aa55c105fd406d3b4ff4fbf4b8a4ff817 | Python | 8,298 | 231 | """
Classes for reading and writing motif data.
"""
from bx.motif.pwm import FrequencyMatrix
class TransfacMotif:
def __init__(self):
self.accession = None
self.id = None
self.dates = None
self.name = None
self.description = None
self.binding_factors = None
... |
eabed4a3c2c4ff4f5af43197e4570ef50d75216b08c091f35b9a83cf666922ca | Python | 8,299 | 187 | from drop import utils
from .Submodules import Submodule
from snakemake import logger
class MAE(Submodule):
def __init__(
self,
config,
sampleAnnotation,
processedDataDir,
processedResultsDir,
workDir,
genome
):
super... |
26dc2f27b08742b3f00e79fd381c7a66c2df8b56be8a9fcecfa78b53334bc261 | Python | 8,300 | 251 | import math
import numpy as np
import torch
import torch.nn as nn
from random import sample
import torch.nn.functional as F
class ConvRF(nn.Module):
def __init__(
self,
in_channels,
out_channels,
padding=0,
stride=1,
dilation=1,
groups=1,
bia... |
70d4b3b2344c290817ed98e725aa9c8d7009f094999912c6678795213b11d3c6 | Python | 8,302 | 221 | """Background worker that runs the pipeline off the Qt UI thread.
``run_pipeline`` is CPU-bound and can take several minutes (wavelet spike
detection, probabilistic thresholding, null-model randomization). Running it on
the UI thread froze the window and made the Stop button cosmetic. This
:class:`QThread` runs it in ... |
0e1b5766b55dcffb689255b7980bba55dda9d2bc9e19b54983b9e1489ec42d30 | Python | 8,303 | 175 | import torch
import torch.nn as nn
from pathlib import Path
from sklearn.metrics import f1_score, accuracy_score, classification_report
from typing import Optional, Union, Tuple
import numpy as np
import time
import os
from .utils.transforms3D import normalize_to_identity_cube, Rotate3DBatch_UnifDist
from .utils.data... |
908a3a29ed0494a1a3e4927f83fbad49a84d31a099be7f761b6d61fdb02f8807 | Python | 8,303 | 239 | import tensorflow as tf
import tensorflow_addons as tfa
class RandomFlip(tf.keras.layers.Layer):
def call(self, x):
x = tf.image.random_flip_left_right(x)
x = tf.image.random_flip_up_down(x)
return x
class RandomRotation(tf.keras.layers.Layer):
def __init__(self, max_angle=45):
... |
918c737fc5666f5e1e003f9fd6363071d16f055fb1d20402d363ffa7b896de5a | Python | 8,304 | 274 | import os
import warnings
from pathlib import Path
from mcp.server.fastmcp import FastMCP
from parsl.config import Config
from parsl.executors import HighThroughputExecutor
from parsl.launchers import MpiExecLauncher
from parsl.providers import LocalProvider
from parsl.utils import get_all_checkpoints
import parsl
f... |
f8f71da9a9ca96f2b5295d8ca43ba44f1476d1b36ef56b785a584002ee2844d3 | Python | 8,305 | 169 | #
# fiberprofile/analysis/flip_tensor.py (from FiberProfileAnalysis/flip_tensor.py)
#
# Reflect the orientation frame of a diffusion tensor NRRD along one or more axes.
#
# This reflects the tensor directions, not the voxel layout: R = diag(sx, sy, sz) is applied to every voxel's
# tensor, D' = R D R^T, i.e. e... |
05024d0c27377a7535f9ddebb95e7f72840f758efab6c1522216eaab7f895170 | Python | 8,306 | 218 | import torch
import torch.nn as nn
from typing import Tuple, Optional
import torch.nn.functional as F
class SeparableConv2d(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, padding=1, bias=False, **kwargs):
super(SeparableConv2d, self).__init__()
self.depthwise = nn.Conv2d(i... |
251663a48321e99e20de4df2a3dcdda52f185cc647141daade22b8fcba753b47 | Python | 8,307 | 260 | from typing import Dict, List, Optional, Tuple, Union, overload
import torch
from torch import Tensor
from torch_geometric import EdgeIndex
from torch_geometric.typing import (
Adj,
EdgeType,
MaybeHeteroAdjTensor,
MaybeHeteroEdgeTensor,
MaybeHeteroNodeTensor,
NodeType,
SparseStorage,
S... |
6f45eaa6efaa7621251a8d1c146f1c4aef8faa071eecd1fcc5ca08d0d8a05a23 | Python | 8,309 | 289 | import os
import sys
import warnings
from importlib import import_module
from importlib.util import find_spec
from typing import Callable
import torch
from packaging.requirements import Requirement
from packaging.version import Version
import torch_geometric
from torch_geometric.typing import WITH_METIS, WITH_PYG_LIB... |
99203bbf0f738b1ee82720b85388c82ac1f90fdf2b1ef442635edbba69da062d | Python | 8,310 | 162 | import sys
sys.path.append('./TEMcode/2024-10-22/run0/script')
from collections import defaultdict
import numpy as np
import torch
import glob
import importlib.util
# Own module imports. Note how model module is not imported, since we'll used the model from the training run
import src.world as world
import json
from t... |
10aa9db4b454bb54aa11c68a84afe0fe71993b91073fbdc331711962ef068764 | Python | 8,311 | 209 | import copy
import torch
import torchvision
from torchvision import datasets, transforms, models
from torchvision.models.resnet import ResNet34_Weights
from torch.utils.data import DataLoader, random_split
import matplotlib.pyplot as plt
import seaborn as sns
from tensorboardX import SummaryWriter
import numpy as np
im... |
4e13564d442af83e903b1ceee4fc62933957e7ebc2be16d9f60a345534ed6168 | Python | 8,311 | 220 | import click as ck
import pandas as pd
from deepgo.utils import Ontology
import torch as th
import numpy as np
from torch import nn
from torch.nn import functional as F
from torch import optim
from sklearn.metrics import roc_curve, auc, matthews_corrcoef
import copy
from torch.utils.data import DataLoader, IterableData... |
2bce7339512c3079637a0ef1bf041246b7a4736e5803d8f88118d2c5034794bc | Python | 8,312 | 258 | # -*- coding: utf-8 -*-
"""
Most code here is from https://github.com/fengwangPhysics/matplotlib-chord-diagram.
It was adapted to our specific needs: size of matrix, order of magnitude of
max/min values, alpha for visualisation, etc.
""" # noqa
import math
from matplotlib.path import Path
import matplotlib.patches as... |
d57be0edae30715d9fa32afe5b450f6c3b9683dccfcb82af33c599f375243718 | Python | 8,314 | 140 | from typing import Union, Tuple
from batchgenerators.dataloading.data_loader import DataLoader
import numpy as np
from batchgenerators.utilities.file_and_folder_operations import *
from nnunetv2.training.dataloading.nnunet_dataset import nnUNetDataset
from nnunetv2.utilities.label_handling.label_handling import LabelM... |
e4da65d8572452fbc6946983fdb8e37e0e756f1be75a09154ed6bfce606f284b | Python | 8,314 | 247 | #!/usr/bin/env python
#
# Handles the transfer queue GUI and also file transfer.
#
# Hazen 08/16
#
import time
from PyQt5 import QtCore, QtGui, QtWidgets
#
# Transfer Queue related.
#
class TransferQueueListViewDelegate(QtWidgets.QStyledItemDelegate):
"""
A custom look for each item, mostly so that we inclu... |
62a815641ca3209add72b6fd0c47c6aed58b872adc640bc00744af58a668230d | Python | 8,315 | 204 | # -*- 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... |
83f3e2dcff91289f8a01496a0e55a0fc4bda4e3dbbf66ba20081784f906528b0 | Python | 8,316 | 207 | """
Grey reconstruction module
This morphological reconstruction routine was adapted from
`CellProfiler <http://www.cellprofiler.org>`_.
Author
""""""
Original author: Lee Kamentsky
Copyright (c) 2003-2009 Massachusetts Institute of Technology
Copyright (c) 2009-2011 Broad Institute
Modified by Chi... |
eae9dfe006f7313d1da333c5e5814b6d68b1e2872d543bf49ca4ef60c41a91cf | Python | 8,316 | 183 |
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 loss.Dice impo... |
952025ea4872df3239d297a8f62b6f476ef8584e5f2210bb572e42b790b0c639 | Python | 8,318 | 207 | import sys, os
import tempfile
from argparse import ArgumentParser
from pathlib import Path
import numpy as np
import pandas as pd
import torch
sys.path.insert(0, str(Path(__file__).absolute().parent.parent))
from trRosettaX2.main_chunk import Folding
from trRosettaX2 import esm
from trRosettaX2.strutils.utils_3d.pr... |
19b7b65b161d6cc3390d2d2463a06ad3f991de2abcdb6af2d0f8dac68df43245 | Python | 8,319 | 245 | """
Resting state analysis
Will replace scripts 18 and 19
"""
import nibabel as nb
import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt
import math
import subprocess
import glob
import os
from nilearn.connectome import ConnectivityMeasure
import itertools
ROOT = '/Users/sebastiandresbach/data/s... |
8c49aa752f6ccee90f6ddec103b725f88b77e4d53f06568dd68b6d3d2ab361e2 | Python | 8,320 | 247 | """Use H-Optimus-0 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 timm
import torch
from torchvision import tr... |
beeb68b3c8c5ca787ddc569070473aaacf36083c7f119dc2fbefd6fef765d4b0 | Python | 8,320 | 173 | """The Results tab: everything you do once a run has finished.
Looking at results was spread across the window. **View report** was a fourth
button in the Run tab's row, beside Run and Stop, which is the row you look at
while something is *running*. **Open bundle…** was in the toolbar, next to New and
Save params, whi... |
10bd5cdddd2ceaea9286ee4d978ece59af42c0b626082256db6ab927616c7b1f | Python | 8,322 | 176 | # Implements Shared Sparsity Confounder Selection suggested by:
# https://arxiv.org/abs/2011.01979
import warnings
import numpy as np
from sklearn.exceptions import ConvergenceWarning
from causallib.preprocessing.confounder_selection import _BaseConfounderSelection
__all__ = ["SharedSparsityConfounderSelection"]
cl... |
8fcb2824b1bf019c92f47cd31666ed86f4c2bdda0953521d4e7a5acd8bc4b83d | Python | 8,323 | 222 | import jax
import jax.numpy as jnp
import matplotlib.pyplot as plt
import glob
import sys
import os
import re
import json
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
plt.rcParams["font.sans-serif"] = ["DejaVu Sans"] # Best available
plt.rcParams["font.family"] = "sans-serif"
plt.rcPa... |
df7f8281477e78b704a62972151ff47341e2e24b7e75263c58a6d5f804e22dd7 | Python | 8,327 | 220 | from argparse import ArgumentParser
from dataset import SATARDataset
import numpy as np
import time
import torch
import torch.nn as nn
from torch.utils.data import DataLoader
from model import SATAR, BotClassifier
from tqdm import tqdm
from utils import null_metrics, calc_metrics, is_better
device = torch.device('cuda... |
512f068f1bb0a4cb405ed53c486c494a9e6ac9ba8ade81a5d323808af0831d2d | Python | 8,328 | 270 | import nibabel as nib
import numpy as np
import nibabel as nib
import numpy as np
def vectorize(img, mask) -> np.ndarray[float]:
"""Vectorize or unpatch an image using a 3D mask.
Behavior
--------
- 1D input + 3D mask -> reconstruct 3D image
- 2D input + 3D mask -> reconstruct 4D image
- 3D... |
567b86ea1eeee274df9cc9f1ecf75b80a0ec14d2b0bb19e759e6653a472f6f7e | Python | 8,328 | 195 | import torch
from einops import rearrange
from einops.layers.torch import Rearrange
from torch import nn
from trRosettaX2.evoutils.attn_conv_e2e import Predictor2D
from trRosettaX2.strutils.structure_module import StructureModuleFullAtom
from trRosettaX2.strutils.utils_3d.rigid_utils import Rigid
def one_hot(x, bin_v... |
215c18c1440491bd80157e2f7e6f16d237977ced2172d731c5759f71165838c0 | Python | 8,330 | 177 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
from __future__ import annotations
import itertools
from pathlib import Path
from typing import Any
import torch
from ultralytics.data import build_yolo_dataset
from ultralytics.models.yolo.detect import DetectionTrainer
from ultralytics.nn.tasks i... |
4d27b02229e09828b88b690b7c49f72f7ee89a1366380e3c93b059395737c8d9 | Python | 8,330 | 207 | # 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... |
0907e2941fc72825e9b435eddeb512da11f2378d09126a276ca702f9281c9052 | Python | 8,331 | 181 | # 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... |
479b18e139b6feedd9c5c51e76ca02447dc06b9a44ca30f592376df2d4b05337 | Python | 8,331 | 183 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Validate the sampling of a gradient table, in terms of how well distributed on
the sphere the b-vectors are.
To do so, the script compares the electrostatic-like repulsion energy [1] of
the inputed b-vectors with the energy of optimally distributed b-vectors. The
same... |
7cc25a8c89397f80f21a241761192a47d7679f3796115d25be095449eaf72145 | Python | 8,331 | 268 | # 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... |
c23c06ef111aff675d080a984669636c7c1b82df47f00fa2d473ee233ee77259 | Python | 8,334 | 260 | import datetime
import pytest
import numpy as np
import pandas as pd
import h5py
import seisbench.data as sbd
def test_das_data_writer_validate_metadata(tmp_path):
with sbd.DASDataWriter(tmp_path / "example_a", strict=True) as writer:
valid_example = {
"record_sampling_rate_hz": 100,
... |
6508c6fc5a30ce439896e1f3a7ddb05bd528e7061c22174e4672743ccd49e9c6 | Python | 8,337 | 198 | """
ECG-based functions.
Author: Dr Raphael Vallat <raphaelvallat@berkeley.edu>, UC Berkeley.
Date: May 2022
"""
import logging
import numpy as np
import pandas as pd
from .detection import _check_data_hypno
from .hypno import _hypno_find_periods
from .io import is_sleepecg_installed, set_log_level
logger = loggin... |
08b27e66b556608381a5d85004b033f78763ddc30a28a737ab01abe0315b8825 | Python | 8,338 | 219 | from typing import Optional
import torch
from torch import Tensor
from torch.nn import LayerNorm, Linear, MultiheadAttention, Parameter
class MultiheadAttentionBlock(torch.nn.Module):
r"""The Multihead Attention Block (MAB) from the `"Set Transformer: A
Framework for Attention-based Permutation-Invariant Neu... |
ad35bb1dad8cc16e94f281c3b63a87780be0a49ff2cb7dfa7b3803b435fd98fb | Python | 8,342 | 143 | # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'hal4000-detached.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_MainWindow(object):
def setupUi(self, MainWindow):
Ma... |
67a56f92af735bfd0cdebe69bfdd005a0289575e3c7336e4e2be666f41dbf326 | Python | 8,345 | 189 | """Interval type-2 fuzzy warning layer.
Converts three quantities the network already produces -- predicted risk, its
short-term trend, and the reliability-gate confidence -- into one of three
operator-facing states. Type-2 rather than type-1 because the footprint of
uncertainty is exactly what a driver-monitoring sys... |
05344f38d5b6a5d0065da30c9ff9cff9ffa4f266d87870efa74b8780cba75f7e | Python | 8,346 | 191 | #!/usr/bin/env python3
# -*- coding: utf-8
"""
Script that simulates data for benchmarking of DestVI.
Created on 2020/02/03
@author romain_lopez
"""
import os
import click
import numpy as np
np.random.seed(0)
from logzero import logger
from utils import get_mean_normal, categorical
from scipy.spatial.distance impor... |
c6ffe553d5129286d1039ba59cd102f44e19b79b77d846543a33e39c3cc0b94a | Python | 8,346 | 165 | """
Gaze analysis routines to process and plot eye-tracking data.
"""
import os
import glob
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from utils.const import SUBJECTS, LABEL_NAMES, LABELS, STIMULUS_SEQUENCES
class GazeAnalysis:
"""
Class for performing gaze... |
b8991ba51cb267bf5f4543b17fa970e13a2585f08d41470e74ac8889d97d366d | Python | 8,347 | 233 | '''Tests for ColorMap and CMSL.'''
from typing import NamedTuple
import pytest
import numpy as np
from zennit.cmap import ColorMap, LazyColorMapCache
class CMapExample(NamedTuple):
'''Named tuple for example color maps used in tests.'''
source: str
nodes: list
CMAPS = [
('000,fff', [
(0x00,... |
fe080a8b5987831f8c52dffc1f1028e527cf87d96434caa65520d85ba167baa8 | Python | 8,349 | 150 | import pandas as pd
from functools import partial
from rdkit import Chem, DataStructs
from rdkit.Chem import MACCSkeys
# from rdkit import rdBase
# rdBase.DisableLog('rdApp.warning')
class Fingerprint():
'''
This class contains some basic molecular fingerprint feature extraction as well as similarity calculati... |
5be9fdbfd7788a35ab6d4d5546678ffc8d03df20732db665ac2925f58a86256e | Python | 8,351 | 203 | # wfield - tools to analyse widefield data - motion correction
# Copyright (C) 2020 Joao Couto - jpcouto@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the Li... |
ad295e42ed3ef2a412c16607571f7521642ca6091faab5bdba70836dfafb3ec5 | Python | 8,352 | 234 | # Generated by Django 3.2.14 on 2022-07-26 09:26
import django.db.models.deletion
from django.db import migrations, models
import cvat.apps.engine.models
class Migration(migrations.Migration):
dependencies = [
("engine", "0056_jobs_previews"),
]
operations = [
migrations.CreateModel(
... |
50e013ed9de021a4bcebc08bd930d910e5b2d2f65e44a70c638e321dcfcd855d | Python | 8,353 | 250 | import os
import warnings
import matplotlib
import numpy as np
import umap
from sklearn.decomposition import PCA
from sklearn.utils import check_array
try:
os.environ["DISPLAY"]
except KeyError:
matplotlib.use("Agg")
import matplotlib.pyplot as plt
def normalize_counts(raw_counts, pseudocount=0.1):
"""N... |
5868a377a2ad5d6b4f62514937054bdb01434797b9cd4826a4d59bee5a45053d | Python | 8,360 | 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... |
8cf4d45ceb585c6d861c4a6bba88e42e58a88879df8a9ecc6392ec329cf2c482 | Python | 8,360 | 162 | from pathlib import Path
import numpy as np
import pytest
from pytest import approx
from brainscore_core.supported_data_standards.brainio.assemblies import BehavioralAssembly
from brainscore_vision import benchmark_registry, load_benchmark
from brainscore_vision.benchmark_helpers import PrecomputedFeatures
from brain... |
66094e9a8de5f009f8355b446df134fdc950002b8508b4a9e0bd02faf6c3d5f0 | Python | 8,361 | 221 | # 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 math
from typing import Any, Optional, Tuple
import numpy as np
import torch
from torch import nn
class Positio... |
80dc1ced80b1dfcd5d9617edcb8d6ab8d2227e004e9810196792eefb9adb3233 | Python | 8,361 | 199 | # -*- coding: utf-8 -*-
import numpy as np
import os
import matplotlib.pyplot as plt
# In[]
# Generate CAD scr file to draw 2D pattern of porous framework with triangle mesh
def CAD_Tri_mesh_jin_20230614(b_width, sx_b_constraint, filename, scrname, COORD_START_POINT, MIN_POROUS, POROUS_CUSTOM):
ele... |
a8369452a558cb9b0d5c8e883f783a2b2f752c9855229a5025a011526fbf685a | Python | 8,364 | 237 | # wfield - tools to analyse widefield data - visualization
# Copyright (C) 2020 Joao Couto - jpcouto@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the Licens... |
be8d9054743328ecd6f1c55c7bd478a5a90867ebcb747a1cfc631a4c4a01d0d5 | Python | 8,364 | 137 | # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'transformix_plugin.ui'
#
# Created by: PyQt5 UI code generator 5.7.1
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_transformix_plugin(object):
def setupUi(self, transformix... |
79032188b6e2ba3e71b2ed1adda9220fe2d626f5f82d4fbdd97f84735c64090a | Python | 8,366 | 226 | #!/usr/bin/env python
"""Smoke test for the GlobusComputeBackend.
Drives the production execution layer against a live Globus Compute
endpoint. Exits 0 on success, nonzero on any failure.
Prereqs (env vars)
------------------
- GLOBUS_COMPUTE_ENDPOINT_ID -- UUID printed by ``globus-compute-endpoint start``.
- (optio... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.