sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
e0aeb10a4612c6557bc55fde348c9eb4dc26d040e80fa5ce98b2019033c673dd | Python | 5,448 | 177 | # -*- coding: utf-8 -*-
# python standard library inputs
import os
import sys
import datetime
import shutil as sh
# external inputs
import numpy as np
from nibabel.freesurfer.io import read_geometry
from nipype.interfaces.freesurfer import SampleToSurface
# local inputs
from ..io.get_filename import get_filename
fro... |
63d6cc86b6f3f50a7e06c3425ebfe95933bb136a07d70bb2fe8feccbb173f797 | Python | 5,449 | 115 | import os
from nipype.interfaces.freesurfer import BBRegister, SampleToSurface, ApplyVolTransform
from nipype.interfaces import afni
import nipype.interfaces.freesurfer as fs
#Must have SUBJECTS_DIR set as per standard Freesurfer conventions.
def register_and_vol2surf(mov, subject_id, out_dir, b0 = None, feature_name... |
bef65c12f9cb3da8cc3ffea5242efc1d8d90a4b510072c2c8b3d00cf438a3a04 | Python | 5,449 | 163 | #############################################################################
# Copyright (C) 2020-2026 MEmilio
#
# Authors: Maximilian Betz, Daniel Richter
#
# 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 compli... |
22a97f74059ca516afb9653eac1bba3633271398da135236ba91abcabf790251 | Python | 5,450 | 142 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Evaluate graph theory measures from structural connectivity matrices from
outputs of diffusion MRI tractography. A length-weighted matrix is
optional but required to extract measures such as: global efficiency,
local efficiency, betweeness centrality, path length, edge... |
2d17639b7f387840088e23b1d4cde02d725307f79452347dcceefc54702a0284 | Python | 5,450 | 155 | import torch
import numpy as np
import torch.nn as nn
from sklearn.metrics import roc_auc_score
from tqdm import tqdm
import torchvision.models as models
class CNN_LSTM(nn.Module):
def __init__(self, hidden_size=128, num_layers=2, num_classes=5):
super(CNN_LSTM, self).__init__()
# CNN layers (ext... |
4b37e5aa3958b72d0729240c0e578f99593c605ec75f1b6e42786b0b4ce9a2bf | Python | 5,450 | 146 | """Custom state initializers with permanent properties between trials"""
import numpy as np
import collections
from moog import sprite
from . import poll_generator
from moog.state_initialization import distributions as distribs
class SkiGameStateInitializer():
def __init__(self, agent_0_factors,
... |
5220e3b2eecdb3bfc753dd4026c126449c8a58d40bae5c91ec2d10fcc3c3dbd2 | Python | 5,450 | 143 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Script to compute Constrained Spherical Deconvolution (CSD) fiber ODFs.
See [Tournier et al. NeuroImage 2007]
"""
import argparse
import logging
from dipy.core.gradients import gradient_table
from dipy.data import get_sphere
from dipy.io.gradients import read_bvals... |
6dbb1fe9648900b2986027bfdfe69ff7cb3a40cd3d607ea51c017d2ec8c77a76 | Python | 5,451 | 155 | from unittest.mock import MagicMock, patch
import cv2
import numpy as np
from brainways.pipeline.brainways_params import (
AffineTransform2DParams,
AtlasRegistrationParams,
BrainwaysParams,
TPSTransformParams,
)
from brainways.pipeline.brainways_pipeline import BrainwaysPipeline
from brainways.project... |
e314519e7572ca634aaaa24b33035e9080fa769f09dcffc588694ec54241f762 | Python | 5,451 | 125 | #!/usr/bin/env python3
"""Stage 6 -- discrimination as a function of label lead time.
Produces the study's primary exhibit: per-participant AUROC against the offset
of the label bin, from retrospective (detection) through prospective
(forecasting), with the observation window, feature set, models and bin width
held fi... |
47366e18e6129099987403fc042faee0bf393fdc07353c48f8ce571b7275269d | Python | 5,452 | 128 | #!/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=['processing.zip'])
tmp_dir = tempfile.T... |
b82b6a249e1720a4cc0d8ae2591edda7c519070b5790b7e5f03131c792150e03 | Python | 5,452 | 149 | """Cache for figures rendered from a bundle.
The batch comparison families are produced by plotters that emit a whole folder
in one call — ``plot_step4_group_comparisons`` writes all 109 of its figures
per invocation and cannot be asked for just one. So a gallery cannot render
lazily as the reader scrolls; it renders ... |
1d07f278c29ad8351ac3f72b10bcf5be21a723b4872f331e4c0fd3b2bd7cbb79 | Python | 5,453 | 136 | from PyQt6.QtWidgets import QWidget, QVBoxLayout, QFileDialog
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
from matplotlib.figure import Figure
import matplotlib as mpl
class CustomNavigationToo... |
72b39a2183d955ad55faf98074b83c9f77f14ddbd7af05973e1eac8962cd35ba | Python | 5,454 | 107 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
"""
YOLO11 Instance Segmentation with Axelera Voyager SDK.
Standalone example using the axelera-rt pipeline API.
No ultralytics dependency at runtime.
Results are rendered by the built-in display app: each SegmentedObject draws its
own mask overlay, ... |
8899ed1bc7ef24676da7e9f2b28ed6d491c8bf81ab01cf85b910e8020c505767 | Python | 5,454 | 131 | # 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... |
420f0c2362722baee0bff31a10e74e634a636d5c61ca17eabf477768f6026eab | Python | 5,459 | 146 | # 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, ... |
5a15a2d27610024ee54b6189d367b4340de5cafc468fe3bed4d8d43b603b49aa | Python | 5,460 | 159 | import os
import yaml
try:
from importlib.resources import files
tmp = files('encore.gui')
except (TypeError, ImportError): # Python < 3.10
from importlib_resources import files
from typing import Any, Dict
from pydantic import BaseModel, create_model, field_validator
def validate_user_parameters(use... |
68d978f71a3e9d03aecdb011479f2b13315fcde10a8660e301a7a0717cc2f528 | Python | 5,460 | 140 | import torch
import torch.nn as nn
import torch.nn.functional as F
import math
class Bottleneck(nn.Module):
def __init__(self, in_channels, growth_rate):
super(Bottleneck, self).__init__()
inter_channels = 4 * growth_rate
self.bn1 = nn.BatchNorm2d(in_channels)
self.conv1 = nn.Conv2d... |
c3e70cb5921e1f62fbb779c225e10d2760a6b0eb556f84ea900b197bffda42e5 | Python | 5,461 | 156 | #! /usr/bin/env python3
"""
Show coronal, transverse and saggital plots in different panels
Depends on:
vtk
pyqtgraph
numpy
tifffile
argparse
tempfile
urllib
"""
__author__ = "Sainsbury Wellcome Centre"
__license__ = "GPL v3"
__maintainer__ = "Sainsbury Wellcome Centre"
import os
import sys
import argparse
from ... |
e90bcadd09150d95df55654a143e95c774382e4d5e4a970c0416887995a3b832 | Python | 5,461 | 157 | import numpy as np
import tifffile
from ome_types import OME, model
from scipy.ndimage import zoom
import os
def generate_pyramid(base_image, num_levels, axes, dtype=None):
"""Generate pyramid levels with exact level count matching reference"""
pyramid = [base_image]
current = base_image
if dtype is No... |
3072ec43fde211a9d71a7288bae53d72ab0ba7dd8954f8f8f03eaa0c23e71902 | Python | 5,462 | 204 | import json
from collections.abc import Callable
from dataclasses import asdict
from pathlib import Path
from typing import Any, Protocol, cast
import numpy as np
import torch
import yaml
from aislib.misc_utils import ensure_path_exists
from eir import __version__
from eir.setup.config_setup_modules.config_setup_util... |
6c00f5154ef5d690303d80e1a4a6229db1da90514c5d792ce2705a7729041bea | Python | 5,462 | 147 | import numpy as np
from collections import Counter
from scipy.cluster.hierarchy import linkage
from scipy.spatial.distance import squareform
from nest.hotspot import differential_expression, hotspot_decomposition
import pandas as pd
def geometry_scores(adata):
# Compute a significance score based on each hotsp... |
b584a19ae0a4b3db5c14113d2841a90031491ddc5bcf0d92ac70fec235e344f6 | Python | 5,462 | 106 | """Examples to show how to estimate of the hyperparameters governing the GMM prior distributions.
This requires images of the desired contrasts along with corresponding label maps (possibly obtained with automated
segmentation methods)
If you use this code, please the SynthSR paper in:
https://github.com/BBillot/Synt... |
634d7760eaa88a0cf404d5fb33b636b9b0df8255b905de089cd6fa7148db1e45 | Python | 5,463 | 129 | import csv
import os
from os.path import join as ospj
import pandas as pd
import re
import sys
import json
"""
This script loads the the probability of hitting GM or WM for each subject and tallies the number of times a given depth is the 'best depth'.
For each person, which depth (1, 1.5, or 2mm) is the one with th... |
53fc0e55997d6928789c3d9fc0af269d8d0a65d047e5365bca3a13b541efd02b | Python | 5,466 | 175 | import os
import pickle
from collections import defaultdict
import numpy as np
import pandas as pd
from typing import Dict, List
def get_neighbors_for_words(word_list, year, freqs) -> Dict[str, pd.DataFrame]:
"""Get neighboring words and their weights for each word in word_list.
Args:
word_list: Li... |
54fcc9166505e9f21a1c2899ea2fe2712af19e2ffcfb8de920002bd5e4ee1a7a | Python | 5,466 | 150 | #############################################################################
# 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... |
eb452d3b6eb99c090070fd3b764489fb06eaf0a5e21f66c7ffdd017b2ad614d6 | Python | 5,467 | 150 | # 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, ... |
597151753129b3ff5bf6e806c64777edfc9f5b11c1b3e1d98cecf72bb46a086d | Python | 5,469 | 146 | import numpy as np
from typing import TypeVar
from argclz import AbstractParser
from neuralib.persistence.cli_persistence import get_options_and_cache, PersistenceOptions
from neuralib.plot import plot_figure
from neuralib.suite2p import get_neuron_signal, sync_s2p_rigevent, Suite2PResult
from neuralib.util.verbose im... |
79417fe2d313eaf58be52abc5c19d6ec12c3cd7aeacc84ab63ad20b2875da81d | Python | 5,472 | 146 | import torch
from torch import nn
from torch.nn import functional as F
from torch.nn import init
from .pooling import build_pooling_layer
from .GLAM import *
class UNet(nn.Module):
def __init__(self, depth=0, pretrained=True, cut_at_pooling=False, img_size = 175,
num_features=0, new_in_chann... |
60ad76631ec94cbd50e4e3ab87a8df49a49f2f12f534033e96fe06d606f66c22 | Python | 5,473 | 146 | # 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, ... |
6dbc11189bae388ba4981c7953ba3a4408a965e270c109c10c587ac86023cecf | Python | 5,473 | 152 | import argparse
import os
import time
import numpy as np
import pandas as pd
import yaml
from evaluation import bayesian_optimization_CRE
from evaluation.CRE_utils import get_time_stamp
def standalone_data_creation():
with open("config.yaml", "r") as file:
config = yaml.safe_load(file)
bo_config = ... |
b2578d94e53f425e41fd02179e701a5478e7e6ed730cbf7997e4545f85aa9ee4 | Python | 5,473 | 153 | from dataclasses import dataclass
from typing import TYPE_CHECKING, Literal
import torch
from torch import nn
from eir.models.fusion.seq_out_fusion_attention import MetaSequenceFusion
from eir.models.input.sequence.transformer_models import (
BasicTransformerFeatureExtractorModelConfig,
parse_dim_feedforward,... |
40746d371ae7112040ca63a63bb9148bf9c3936654fdb5bafd32d3788bc46570 | Python | 5,475 | 195 | # -*- coding: utf-8 -*-
"""Field map utilities."""
import os
import uuid
import nibabel as nb
from .. import execute_command
from ..io.filename import get_filename
__all__ = ["prepare_fieldmap_fsl", "fugue_fsl", "apply_fieldmap"]
def _bids_to_cardinal(pe_dir: str) -> str:
"""Convert BIDS PE dir (i, i-, j, j-,... |
a9f4a5902fe6ed72f8dca89bd32b05faab1247c99f10f9e87f049af6fac7d360 | Python | 5,475 | 147 | """
Predicted concentration vs estimated concentrations
for the Look Locker sequence with a given SNR
"""
import matplotlib.pyplot as plt
import numpy as np
import click
from pathlib import Path
import hashlib
from look_locker import curve_fit_wrapper, OptimizeWarning
from common import compute_T1, compute_c
import m... |
4f223a7242cd839cf52c39c39cfd4ef38b8fb6bd81bca979f81a4c67b2129085 | Python | 5,476 | 165 | #!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
import os
import sys
import re
from subprocess import Popen, PIPE
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
CNN_DIR = os.path.dirname(SCRIPT_DIR)
MATERIALS = {
'CeO2': {
'model_folder': 'model_CeO2_100epochs_digit_zero0p0075_lp0p005_May13_202... |
9474d79971dba4fe75e3a0745b959057a370ce0d3fa323ca9750d4770a2b4fcb | Python | 5,476 | 139 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
"""Round-robin the unassigned jobs of a task across a set of annotators and
write a CSV report of the assignments (job_id, previous_assignee, new_assignee).
The user API supports server-side search within an organization, so you rarely
need to know ... |
c13dccd1e5b7431b50fbf23a32636b76e83a59981fe7995336daf3986bc61fdf | Python | 5,476 | 126 | import torch
import re
def read_profile_info(file_name):
dram_sum = [0, 0, 0, 0]
item_num = [0, 0, 0, 0]
ops = [0, 0, 0, 0, 0, 0]
write_l2 = 0
peak_mem = 0
try:
with open(file_name, "r") as f:
lines = f.readlines()
filter_line = False
find_metric = 0... |
548e71a9138a763e3b56a24ea61668c1c85a78688cf0bb85a562ff136e609dfe | Python | 5,478 | 149 | from scipy.spatial import cKDTree as KDTree
import numpy as np
import pandas as pd
from scipy import stats
from collections import defaultdict
def is_outlier(points, thresh=7): #taken from https://stackoverflow.com/questions/22354094/pythonic-way-of-detecting-outliers-in-one-dimensional-observation-data
"""
R... |
a49de4690885bdef0833bea580bf6d41d3f089dd49202b0f0952812fb7e93b35 | Python | 5,479 | 115 | # 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, ... |
f127848e09b21021907d97109b4d3501574570cc6a64b1558199a6166ebbe0b2 | Python | 5,479 | 221 | #!/usr/bin/python
#
## @file
#
# This controls the IX3 microscope using micro-manager.
#
# Hazen 11/13
#
import MMCorePy
import time
import traceback
active = True
def initialize(device_name):
mmc.loadDevice(device_name, "OlympusIX83", device_name)
mmc.initializeDevice(device_name)
try:
# Start micro-ma... |
fe546e42fdf9b1ba54c90153353fec42e04fb70cee067e710ace3f09a1fad396 | Python | 5,480 | 149 | # -*- coding: utf-8 -*-
# @Author : LG
import os
from PyQt5 import QtCore, QtGui, QtWidgets
from ISAT.configs import *
from ISAT.ui.category_setting_dialog import Ui_Dialog
class CategorySettingDialog(QtWidgets.QDialog, Ui_Dialog):
def __init__(self, parent, mainwindow):
super(CategorySettingDialog, s... |
35bb1413e34c141ae414eca94ec0a0d4e3b1a9583c63449a3a38e39159f945a9 | Python | 5,481 | 173 | # Copyright 2014-2015 Numenta Inc.
#
# Copyright may exist in Contributors' modifications
# and/or contributions to the work.
#
# Use of this source code is governed by the MIT
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT.
import os
import pandas
from nab.sweeper import ... |
1c35f0848169cfd7c7056ba50c9f8ab2b98d5727996483bf2c295cdc731b7700 | Python | 5,482 | 129 | import functools
import hashlib
import torch
import torch.nn as nn
from diffusers import AutoencoderKL
from brainscore_core.supported_data_standards.brainio.s3 import load_file
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper, load_preprocess_images
from brainscore_vision.model_helpers.c... |
238952a8fd0805c657b51db386b3082eb1c69e407471b3900b81fca37b3a171c | Python | 5,482 | 129 | import functools
import hashlib
import torch
import torch.nn as nn
from diffusers import AutoencoderKL
from brainscore_core.supported_data_standards.brainio.s3 import load_file
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper, load_preprocess_images
from brainscore_vision.model_helpers.c... |
3d3ffa938d1885813d8c6e32d64109dfcfa94275471c566f9dff8921f33ebd3a | Python | 5,482 | 129 | import functools
import hashlib
import torch
import torch.nn as nn
from diffusers import AutoencoderKL
from brainscore_core.supported_data_standards.brainio.s3 import load_file
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper, load_preprocess_images
from brainscore_vision.model_helpers.c... |
5598293a9151f2474607bc7b3c3d3e8c6f7605bc8df3af4bf533f2e7432ee71b | Python | 5,482 | 129 | import functools
import hashlib
import torch
import torch.nn as nn
from diffusers import AutoencoderKL
from brainscore_core.supported_data_standards.brainio.s3 import load_file
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper, load_preprocess_images
from brainscore_vision.model_helpers.c... |
61ee6e5791caa52a9b0f40bf2798e2be959871803c094085f9d812210c052fdb | Python | 5,482 | 163 | import math
from collections.abc import Callable
from typing import TYPE_CHECKING
import torch
from torch import nn
from eir.models.layers.mlp_layers import MLPResidualBlock, ResidualMLPConfig
from eir.models.models_utils import (
calculate_module_dict_outputs,
create_multi_task_blocks_with_first_adaptor_bloc... |
72571182497e8ca3e19441410fed934d9932edc990369991529a5cf6041f1a39 | Python | 5,482 | 129 | import functools
import hashlib
import torch
import torch.nn as nn
from diffusers import AutoencoderKL
from brainscore_core.supported_data_standards.brainio.s3 import load_file
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper, load_preprocess_images
from brainscore_vision.model_helpers.c... |
739ee23c1751b1e5674b3228f08093570b39059529ee32dc178bcb92cf356d0d | Python | 5,482 | 147 | import numpy as np
import pandas as pd
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score, matthews_corrcoef, auc, roc_curve, \
roc_auc_score
from sklearn.metrics import classification_report
from sklearn.metrics import confusion_m... |
9f230dcd70ed5ea978edb35b0e6914ff14a7fdbbb1b74db61c4a233118e23380 | Python | 5,482 | 129 | import functools
import hashlib
import torch
import torch.nn as nn
from diffusers import AutoencoderKL
from brainscore_core.supported_data_standards.brainio.s3 import load_file
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper, load_preprocess_images
from brainscore_vision.model_helpers.c... |
5c8ab92469b060c13c3abae7a968d7ffb665fb12989dd9a95f736599775fcff2 | Python | 5,483 | 169 | # 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.
from typing import Optional
import torch
from torch import nn, Tensor
from .sam.transformer import RoPEAttention
from .... |
600e1464e7791e72e077bf173a0f8d9c8658f4cc8493319d600f99fa4abb90be | Python | 5,483 | 146 | import numpy as np
import tifffile
from ome_types import OME, model
from scipy.ndimage import zoom
import os
def generate_pyramid(base_image, num_levels, axes, dtype=None):
"""Generate pyramid levels with exact level count matching reference"""
pyramid = [base_image]
current = base_image
if dtype is No... |
94387645bdf86e814d78b807d68f129daa3dbd40a7d88457b65064540d26dd78 | Python | 5,483 | 153 | # -*- coding: utf-8 -*-
from dipy.data import get_sphere
from dipy.reconst.shm import sh_to_sf_matrix, sph_harm_ind_list
import numpy as np
from scipy.special import legendre_p_all
from scilpy.reconst.utils import find_order_from_nb_coeff
from scilpy.tractanalysis.voxel_boundary_intersection import\
subdivide_str... |
a69269f5213d26f747f318be1f8cbb5896565f7eebf7a0078c48a6d8e4f4b513 | Python | 5,483 | 173 | #!/usr/bin/python
#
## @file
#
# This script is used for camera calibration. It records the sum of x and
# the sum of x*x for every pixel in every frame.
#
# Hazen 12/16
#
import numpy
import sys
import time
import spinnaker
if (len(sys.argv) != 4):
print("usage: <camera> <filename> <number frames>")
exit()... |
aaa17f5f8dd430c5c3118d2392ca47763aca7f6e906b402579d73a22b64b56cb | Python | 5,484 | 156 | # SMIntegration: Spatial Multi-omics Integration Platform
# ==============================================================================
#
# Purpose:
# Ingests raw spatial metabolomics data (text format) and converts it into
# the standard SpatialData (Zarr) format used by the pipeline.
#
# Input Requirements:
#... |
449b5ab0ee90ecfa77a1810e5ab6dfd83118b927ee2993ac17623bf9e2439e80 | Python | 5,485 | 162 | from typing import Any, Dict, List, Optional, Tuple, TypeVar, Union
import torch
from torch import Tensor
from torch_geometric.data import Data, HeteroData
from torch_geometric.data.storage import EdgeStorage
from torch_geometric.index import index2ptr
from torch_geometric.typing import EdgeType, NodeType, OptTensor
... |
d744390dd466e4f606378aab0eea699b924bfbac4948a2070f44906dfef1700a | Python | 5,489 | 136 | """
DyNeMo: Regression Spectra
==========================
In this tutorial we calculate subject and mode-specific spectra using a trained DyNeMo model and **source space** data. Here, we should **not** use the prepared (e.g. TDE-PCA) data.
"""
#%%
# Download source data
# ^^^^^^^^^^^^^^^^^^^^
# In this tutorial, we'l... |
e078279eb75faeaaedbf2c0d5eae068c9a49908b7126559df7d3b5a80cff6586 | Python | 5,489 | 147 | import ijson
from pathlib import Path
import torch
import numpy as np
import time
import csv
import statistics
from urlextract import URLExtract
from transformers import (
pipeline,
BertTokenizerFast,
BertModel,
)
root_dir = Path.cwd().parent.parent.parent
dataset_dir = root_dir / 'datasets'
cresci_15 = da... |
fb86dd49c41f0dc19ac8bc0736bd5ecd8ac2eafb3aa89319a3d508deecd65b82 | Python | 5,489 | 155 |
'''
This script accept a input sorted sam file, a output sam file, and a mismatch rate, then it will remove
duplicates based on the barcode + UMI (edit distance <= 1), and chromatin and start site, at the same
time, it will output the duplication number for each read, and generate the histogram plot for the read
per d... |
484dc1d3c1885066e38a80d13b9c8a7a7f6aa38212e563a0073737e21fe068fc | Python | 5,490 | 89 | import GTF
import pandas as pd
import networkx as nx
from pykeen.triples import TriplesFactory
# 1. split train2, valid and test
# 1.1. load corrected lnctard relations https://github.com/chcomet/nbfnet-gr/blob/master/data/silver/relations.csv
lnctard = pd.read_csv("../silver/relations.csv", sep="\t", header=0, encod... |
4746087ce030672a1bc0a5274f151f983cd6ab1e43afd051fd795dc76bee35d4 | Python | 5,491 | 130 | import math
import numpy as np
import scipy.special
import torch
from distances import CosineSimilarity
from utils import common_functions as c_f
from utils import loss_and_miner_utils as lmu
from losses.base_metric_loss_function import BaseMetricLossFunction
from losses.mixins import WeightRegularizerMixin
class L... |
74f2da80799917ac91ae03b3002c513003708faeecff661c9de36aa2932e9597 | Python | 5,491 | 199 | from __future__ import annotations
import os
from collections.abc import Callable
from dataclasses import dataclass
from pathlib import Path
import pytest
from PySide6 import QtWidgets
from pytestqt.qtbot import QtBot
from labelme._app import MainWindow
from ..conftest import close_or_pause
from .conftest import Ma... |
8c6651130f2e8a93934b1e5ecc618618c068460f321f581a78d9fffa57aa9792 | Python | 5,492 | 176 | """
Blender script: batch-export HUMOTO FBX joint positions → COCO-17 CSVs.
Usage (no sudo required — Blender reads FBX natively):
blender --background --python scripts/humoto_to_csv.py -- <humoto_dir> [<output_dir>]
Arguments (after --):
humoto_dir : directory containing *.fbx files (HUMOTO dataset)
ou... |
0ba6b2ee20dc3640adaf7a102fed973c5ec047924c889d0291c04b2b7888cb38 | Python | 5,493 | 149 | import torch
from torch_geometric.data import DataLoader
import torch.optim as optim
import torch.nn.functional as F
from torch.utils.tensorboard import SummaryWriter
from torch.optim.lr_scheduler import StepLR
from gnn import GNN
import os
from tqdm import tqdm
import argparse
import time
import numpy as np
import r... |
2146e5092bb1aad792fcb9eb11cf5b18354e887732efe7d81ca72769f776d470 | Python | 5,497 | 183 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# mmsplice documentation build configuration file, created by
# sphinx-quickstart on Wed Sep 19 10:12:47 2018.
#
# 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
# a... |
c5345a6f22062303bad4b9af8a7899a459a778c455168a507389e7fa9f0768dc | Python | 5,497 | 158 | """resnet in pytorch
[1] Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun.
Deep Residual Learning for Image Recognition
https://arxiv.org/abs/1512.03385v1
"""
import torch.nn as nn
class BasicBlock(nn.Module):
"""Basic Block for resnet 18 and resnet 34
"""
#BasicBlock and BottleNeck block
... |
ee1eafcd3cd6f2fbfe66a30ecf60d5f071cd802f5588eacdec847d77704f0d9f | Python | 5,497 | 168 | import gc
import os
import os.path as osp
import random
import subprocess as sp
import sys
import warnings
from collections.abc import Mapping, Sequence
from typing import Any, Tuple
import torch
from torch import Tensor
from torch_geometric.data.data import BaseData
from torch_geometric.typing import SparseTensor
... |
f8602a2a916a634998538f14eed36a996f2a61f46148f3b477b18cca0d76eb7c | Python | 5,500 | 114 | from unittest.mock import MagicMock, patch
from brainways.utils.atlas.brainways_atlas import BrainwaysAtlas
def test_bounding_box(mock_atlas: BrainwaysAtlas):
box = mock_atlas.bounding_box(0)
assert box == (0, 0, mock_atlas.shape[1], mock_atlas.shape[2])
def test_brainways_atlas_singleton():
with (
... |
15f9eea78c601f2155ac046de17117af6098e060e9556e2e63ba30450789ceeb | Python | 5,501 | 153 | from __future__ import annotations
import io
from typing import Final
import numpy as np
import PIL.Image
import pytest
from PySide6 import QtGui
from labelme._utils import _image as image_module
from .util import data_dir
from .util import get_img_and_data
def test_img_b64_to_arr() -> None:
img, _ = get_img_... |
6dd0a56dabecd921ede26ab01b1c9c606850f8199cdd0128e8ac5d5fe10018a3 | Python | 5,502 | 177 | import logging
from collections import Counter
from typing import Dict, List, Optional
import numpy as np
import pandas as pd
from brainglobe_atlasapi import BrainGlobeAtlas
from skimage.measure import regionprops_table
from brainways.pipeline.brainways_params import BrainwaysParams
from brainways.pipeline.brainways_... |
394809b11ecce439e39723c59182c7b42eac0136193a30da86c8881e7fdb7a4d | Python | 5,503 | 148 | # -*- coding: utf-8 -*-
# @Author : LG
from .model_builder import build_sam3_image_model, build_sam3_video_model
from .model.sam3_image_processor import Sam3Processor
from typing import Optional
import os
import torch
import numpy as np
from torchvision.transforms import v2
from PIL import Image
bpe_path = os.path... |
5f7a6c8713a33dc37c73f50359bee48d45c9cdd879ee4d630a8d5f55e76df25d | Python | 5,503 | 194 | import io
import sys
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.init as init
from functools import partial
activation_dict = {
'GELU': nn.GELU(),
'ReLU': nn.ReLU(),
'LeakyReLU': nn.LeakyReLU(),
'Tanh': nn.Tanh(),
'SiLU': nn.SiLU(),
'ELU': nn.ELU(),
'S... |
70f364d5776f7ceba79f745df6884d6d187c2ed1f0e7e0cf298a74e0532d0595 | Python | 5,504 | 208 | """ Activations (memory-efficient w/ custom autograd)
A collection of activations fn and modules with a common interface so that they can
easily be swapped. All have an `inplace` arg even if not used.
These activations are not compatible with jit scripting or ONNX export of the model, please use
basic versions of the... |
409163fad5666584575844f55ab4ed708106082840081e9ca2db27dec61d3826 | Python | 5,505 | 145 | # -*- coding: utf-8 -*-
"""
Updated for large data processing with memory management and debugging.
"""
import numpy as np
import vtk
import csv
from os.path import exists
import scipy.stats as sp
import psutil
# Define paths and filenames
path = "INSERT_PATH_HERE"
fileNames = [
"OAS1_0009_MR1_atrophy_1R_last_tim... |
1b478cba10d8d05f58a8c3c36a433b4f79fd160bb21e36386f30e87ef5d29600 | Python | 5,506 | 147 |
def mist_modules(mist_directory, resolution="122"):
"""
Return a list of the modules contained in the MIST atlas
Parameters:
mist_directory (str): Path to the MIST directory
resolution (str): Resolution (you have to check which resolutions are valid)
Returns:
r... |
63ef3803df59a5b788c3e8c3037c09a7397c713403bc3444c2848b657ba2f807 | Python | 5,506 | 162 | # mypy: disable-error-code="method-assign"
from dataclasses import replace
from unittest.mock import MagicMock
import pytest
from brainways.pipeline.brainways_params import AtlasRegistrationParams
from brainways.project.brainways_subject import BrainwaysSubject
from brainways.project.info_classes import BrainwaysPar... |
882b4cbdc89669b34f887d59ed264ce082681f3abe6c4943f3c6b65441883749 | Python | 5,506 | 115 | """Tests for data-driven node-cartography boundaries (TrialLandscapeDensity port).
Run from the repo root::
uv run python python/test_pipeline_landscape.py
Covers ``network_metrics._optimal_1d_split_boundaries`` (deterministic optimal
1-D k-means) and ``network_metrics.trial_landscape_density`` (port of
``TrialL... |
c27862513d96c5284fc33a3d346ba9077329257f79538613a49f0e7f02865acd | Python | 5,506 | 164 | from pathlib import Path
from typing import TYPE_CHECKING
import numpy as np
from tests.setup_tests.setup_modelling_test_data.setup_targets_test_data import (
get_current_test_label_values,
get_test_label_file_fieldnames,
set_up_label_file_writing,
set_up_label_line_dict,
)
from tests.setup_tests.setu... |
dee99b8c75df298cdfd5a2aca2d670fcb05dacd73f68e16c046752781ba1ddd1 | Python | 5,508 | 139 | from pathlib import Path
import h5py
import numpy as np
import pandas as pd
import seisbench
import seisbench.util
from .base import WaveformBenchmarkDataset, WaveformDataWriter
class STEAD(WaveformBenchmarkDataset):
"""
STEAD dataset from Mousavi et al.
Using the train/test split from the EQTransform... |
97b7dd71c17b2492080c216500c61124413fb5f3e1701c9a43d85131b9fcb818 | Python | 5,509 | 137 | from itertools import product
import numpy as np
import pytest
import torch
from mcmlnet.utils.knn_cuml import CuMLKNeighbors
class TestCuMLKNeighbors:
"""Test cases for the CuMLKNeighbors class."""
def setup_method(self) -> None:
"""Setup method to initialize common variables."""
self.X_fl... |
887e8edd4ab2ba280c4ddf5c5b4b5e1b9845caa3d66d732ade47f9ce1e1445b0 | Python | 5,510 | 142 | import math
import torch
import numpy as np
import random
def gaussian_kernel(
sigma: float, k: float=1, size:float=15, norm:bool=False
) -> torch.tensor:
"""Returns a 2D Gaussian kernel.
:param sigma (float): standard deviation of the Gaussian
:param k (float, optional): height of the ... |
c6d9260656a24d826128b68c95d0b7798106d04f4244a77f3b1856573f58e690 | Python | 5,510 | 165 | import collections.abc as collections
from pathlib import Path
from types import SimpleNamespace
from typing import Callable, List, Optional, Tuple, Union
import cv2
import kornia
import numpy as np
import torch
class ImagePreprocessor:
default_conf = {
"resize": None, # target edge length, None for no ... |
9c133f7554ae63a624284093d6379214d3a3c368f0166599649c2e3b40a34dcb | Python | 5,512 | 144 | # Copyright (c) DP Technology.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn.functional as F
try:
import unicore_fused_softmax_dropout
HAS_SOFTMAX = True
except:
print("fused_softmax is not installed... |
1e8293125cbd60717c2d9a8abc9af483d6bd07496dc8ebeee830a5779d885cf1 | Python | 5,513 | 155 | from spikingjelly.activation_based import functional
import dataset
import os
import sys
import re
import datetime
import numpy
from models import ann_resnet, ann_vgg, snn_resnet, snn_vgg, spikingjelly_resnet, spikingjelly_vgg
from conf import global_settings as conf_set
def get_network(net_name, datasets='cifar10')... |
2d65eb9178257bd608ada398d888d7bf23507699005695e894811abd27b22d8d | Python | 5,516 | 187 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
import numpy as np
import pandas as pd
import re
from tensorflow.keras.models import Sequential
import keras
from tensorflow.keras import optimizers
from tensorflow.keras.layers import Dense, LeakyReLU
from sklearn.pipeline import make_pipeline
from scikeras.wrappers ... |
19d18bff81aa82243f108a06012912a4191bf6a0df78554313a376df60a6a09c | Python | 5,517 | 151 | import numpy as np
from sklearn.preprocessing import LabelEncoder
from sklearn.metrics import f1_score, accuracy_score, confusion_matrix
from sklearn.calibration import calibration_curve
import matplotlib.pyplot as plt
import seaborn as sns
def plot_loss_curve(train_loss, val_loss, test_lost, run_name, ran_search_num... |
4f313ba1745830cb8b6faf1b5fb19931cb93458da7e0e69f60c78df77672835a | Python | 5,517 | 181 | # -*- coding: utf-8 -*-
"""
Pleiotropy comparison: defect buffering
"""
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from scipy.cluster.hierarchy import dendrogram
from matplotlib import cm
import seaborn as sns
from scipy.stats import pearsonr, spearmanr
from sklearn.decompos... |
bd3f36edbbe24c978fc529bdd71a9ec9b886a919320b6efcddd820557a5f4181 | Python | 5,517 | 155 | """Plot the results of multidimensional scaling (MDS) applied jointly on
NSD-synthetic and NSD-core's first two scan sessions.
Parameters
----------
ncsnr_threshold : float
Lower bound ncsnr threshold of the kept vertices: only vertices above this
threshold are used.
zscore : int
Whether to betas were z-score [1] o... |
a2cafdef03ae07978a345c5ca3a2ab8c41cc5a37ed98b87b892d51751ce4eff0 | Python | 5,519 | 108 | #!/usr/bin/python
#########################################
# Author: Yunjiang Qiu <serein927@gmail.com>
# Modified by: Armen Abnousi
# File: restriction_cut.py
# Create Date: 2015-02-27 16:46:15
#########################################
import sys
import argparse
from Bio import SeqIO
from Bio.SeqUtils import GC
imp... |
f25d5b93984a7ec2246b286ba9515221f6a2c30cc3e92037bc9b21ca80e15167 | Python | 5,519 | 118 | from torch import nn, cat as tcat, tensor, save as tsave, load as tload, no_grad, zeros
from torch import normal, rand, exp, log, randn, arange, sin, cos, matmul, normal
import torch.nn.init as init
from numpy import sqrt, linspace, meshgrid, concatenate, newaxis, polyfit, polyval
from dlim.layers import Block
from dl... |
13f0ac88adf2f1d851e3d39cc86cf35ca446fe61302cd437aaa47879b07072e0 | Python | 5,520 | 132 | import os
import subprocess
import nibabel as nib
import time
import shutil
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... |
ffa0765114082fd51999ca3daf934b609a2a4085538fd053932fb46c103a252a | Python | 5,520 | 186 | # This file is part of connectome-manipulator.
#
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2024 Blue Brain Project/EPFL
"""Various utility functions"""
import json
import os
from pathlib import Path
from typing import Any, Dict
import numpy as np
def _apply_recursively(func, obj, origin=(0, 0, 0)):
... |
5b915d515ecb4bf2ffe5d44ad1a627eaeb463961d079766e12f1f6e493177e24 | Python | 5,521 | 155 | #!/usr/bin/env python
"""Agent + MCP + EnsembleLauncher demo on an HPC compute node.
LLM agent on the compute node drives a local ``mace_mcp_hpc``
subprocess whose backend is ``ensemble_launcher``. Same 5-molecule
thermo screen as the direct demo, but driven natural-language.
Run inside ``qsub -I`` on Polaris/Aurora.... |
850bfeadc76103245bf926b289fa2bb60c606fcebce9090d699f88b662ddb83f | Python | 5,522 | 150 | # 786
import pandas as pd
import numpy as np
import subprocess as sp
import sys, re, os, glob
from collections import *
def system(x):
return sp.check_output(x, shell=True, executable="/bin/bash").strip()
tab_file = sys.argv[1]
path = sys.argv[2]
log = sys.argv[3]
if len(sys.argv) > 4:
chrom1 = sys.argv[4]
... |
bedad85b54a51bac3ed2544ba374b8d0d16ae05b6b13fd0b543b1b1e2dcf309b | Python | 5,524 | 173 | """
Variant: numpy-vectorized (L3 — batch NumPy, no per-peak function calls)
Instead of calling ``_gaussian_eval`` once per peak inside a ``while`` loop,
all Gaussian peaks are accumulated in a single batched expression:
z = (x[None, :] - centers[:, None]) / sigmas[:, None] # (K, N)
total = ((amps / (s... |
cab436a3bdb252471e662e7a0e9c139d5756ed0261815b57b6c0f8fc75095c92 | Python | 5,524 | 133 | """Demonstrates how to create and fit a basic model using NEMS."""
import numpy as np
import matplotlib.pyplot as plt
from nems import Model
from nems.layers import LevelShift, WeightChannels
from nems import visualization
# NOTE For all tutorials:
# If you are having trouble viewing graphs, add plt.ion() or plt.sho... |
a04e412f3ecc6d56c01a9b852ba6725be53c9d02e6f0a75bea7e07dea048b7e6 | Python | 5,525 | 100 | # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'D:\PycharmProjects\ISAT_with_segment_anything\ISAT\ui\video_to_frames.ui'
#
# Created by: PyQt5 UI code generator 5.15.11
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unles... |
38371e4fb468588942794cc4e919a60978745764ac07d91ae9fd52c06d502c5c | Python | 5,526 | 143 | from collections.abc import Sequence
from pathlib import Path
from typing import TYPE_CHECKING
from eir.experiment_io.experiment_io import load_serialized_train_experiment
from eir.experiment_io.io_utils import get_run_folder_from_model_path
from eir.models.model_setup_modules.meta_setup import (
MetaClassGetterCa... |
6416050a52e4dd878711c5f345196a6e518c10a7fd366f0846de600da757ad28 | Python | 5,527 | 127 | import torch
from torch import nn
from torch import Tensor
import torch.nn.functional as F
from einops import rearrange
from einops.layers.torch import Rearrange
class MSCNet(nn.Module):
def __init__(self, f1=16, pooling_size=52, dropout_rate=0.5, number_channel=22):
super().__init__()
# Multi-scal... |
310705f20413f6a538122d5106a282e405525840cf2c9b9ff18148f150c03cdd | Python | 5,528 | 128 | """
Support for masking out sites in alignments based on sequence quality. Both
simple masking of regions below some threshold and masking using the
neighborhood quality standard (NQS) are supported. Uses sequence quality
values stored in a `bx.binned_array.FileBinnedArray`.
"""
from bx.align.sitemask import Masker
fr... |
e81b2f0b7d34d469b436d5c2490a434383a9b4c6e570031b06231260d721f988 | Python | 5,528 | 58 | from testsetclass import TestsetClass
class RSE43(TestsetClass):
def __init__(self):
self.weak = 1.0
self.molecules = ['E15', 'E41', 'P6', 'P3', 'E26', 'E1', 'E4', 'E33', 'P36', 'E19', 'E45', 'P4', 'E7', 'P27', 'P32', 'E40', 'E37', 'E44', 'P5', 'E36', 'E31', 'P29', 'P8', 'E12', 'P26', 'E18', 'E27'... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.