sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
e99ab8f36cfd519dc4f67736b09f234161a87ffac24a340d56e5e9fe9f4fa1cb | Python | 5,616 | 111 | # SPDX-FileCopyrightText: 2024 Blue Brain Project / EPFL
#
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Computes coupling coefficient (correlation of (binned) spike train with the mean of the whole population)
author: András Ecker, last update: 02.2024
"""
import os
import numpy as np
import pandas as pd
import s... |
4942f8e22fd6829b04c8a77c455ac14b7aa9516f06fa5813472d4dd0d569e0ba | Python | 5,617 | 145 | """
Apply the Domain Adaption Algorithm on the SEED Dataset
=======================================================
In this tutorial, you'll learn how to utilize TorchEEG's Associative Domain Adaptation (ADA) algorithm to address the cross-subject emotion recognition challenge using the SEED dataset.
"""
###########... |
fb1918a89669b57e801637ecd264c8e16fcf117e814688cb775ed807cdcb3116 | Python | 5,617 | 163 | import torch
import torch.nn as nn
import torch.nn.functional as F
from ..initializer import create_initializer
class BasicBlock(nn.Module):
def __init__(self, in_channels, out_channels, stride, drop_rate):
super().__init__()
self.drop_rate = drop_rate
self._preactivate_both = (in_chann... |
00deccca6cdfbf7bf2a7026a91cc1e2e66c5512451552203e7a8ca7fa9bcf0e4 | Python | 5,619 | 124 | '''
Description:
The main class of our scNODE model.
Author:
Jiaqi Zhang <jiaqi_zhang2@brown.edu>
'''
import torch
import torch.nn as nn
import torch.distributions as dist
import numpy as np
from model.layer import LinearNet, LinearVAENet
# ===========================================
class scNODE(nn.Module):... |
8410ac7ffe916e8bc04127c49ac9c021cde9e242276ef78eac9e7a5a2d871e03 | Python | 5,619 | 133 | """Exercise actual pretrained inference through the desktop worker and export evidence.
Run from the project root with PYTHONPATH=src. QT_QPA_PLATFORM=offscreen uses
the real VTK EGL renderer for unattended validation, not the native interactor.
"""
from __future__ import annotations
import argparse
import json
from ... |
9f75e68f4cfbf0207ac355bbbea4ecc9d79205089e05058321f28afb2f082436 | Python | 5,621 | 141 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... |
e00f092bf3b548abd35b44d9be60c0614271ecba8499d340812c9d05e2c7bca0 | Python | 5,621 | 122 | import os
from typing import Tuple, Union
import numpy as np
import pandas as pd
from sklearn import model_selection
from torcheeg.datasets.module.base_dataset import BaseDataset
from ..utils import get_random_dir_path
from .utils import create_subset, ensure_cache, read_indices, write_indices
def train_test_split_... |
1cdc7473670fa1e9a232444b3fb45731cc95e53f62daed8e1f6ef53808852feb | Python | 5,622 | 165 | import json
import sys
import os
import datetime
import numpy as np
from PIL import Image
from shutil import copyfile
import SimpleITK as sitk
from src.utils import file_utils as futils
from src.utils import sitk_utils as sutils
Image.MAX_IMAGE_PIXELS = 933120000
def get_paths(dir, extensions=lis... |
c355d4889d8eb7f31d64eb8e92984c4b824eaced8c1bdfcc0770801a4fdbf83e | Python | 5,622 | 98 | #!/usr/bin/env python
from __future__ import print_function
import random
import numpy as np
from pybullet_tools.utils import connect, load_model, disconnect, wait_if_gui, create_box, set_point, dump_body, \
TURTLEBOT_URDF, HideOutput, LockRenderer, joint_from_name, set_euler, get_euler, get_point, \
set_joi... |
8cca5a0e5911e989070969967fe64c7d89382008eabac165df79b212cf5e69eb | Python | 5,624 | 156 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... |
af032a5b40cd1c7a3d4972af5303640341a9afd9a4f9eb8c55a9e7607ce2637c | Python | 5,624 | 123 | """Prediction-interval coverage for interval-censored survival outcomes."""
from __future__ import annotations
import numpy as np
from SurvivalEVAL.nonparametric_estimator.single_event import TurnbullEstimatorLifelines
def coverage_ic(
pred_l: np.ndarray,
pred_r: np.ndarray,
obs_l: np.ndarray,
obs_... |
96cd93903127d613565b9a64b9b814b7cae6f2dc6ce99cd3764b4970ab541ab8 | Python | 5,625 | 164 | import bct
import numpy as np
from tqdm import tqdm
from sklearn.utils import check_random_state
def strength_preserving_rand_sa_energy_thresh(A, rewiring_iter = 10,
energy_thresh = 0.0001,
max_stage = 1000,
... |
bca35398fc0e7fab55e2d3af506cd348d5b2ca549a5407fb9cf1d10d80a721ac | Python | 5,625 | 145 | import os
import inspect
import importlib
import torch
from torch import nn
from torch import optim
from torch.optim import lr_scheduler as scheduler
from torch.utils.data import dataset
from torch.utils import cpp_extension
from torch import distributed as dist
from torchdrug import core, data
from torchdrug.core im... |
cab9dd7bf207e32731413ebcfd580c231602f8d7055f1907de9916297f8c684a | Python | 5,625 | 180 | # Node-group asset "Transform Mix" (GeometryNodeTree), dumped by nodebpy.assets.dump_library.
# Rebuild the library with nodebpy.assets.build_library (nodebpy build).
# _build_group() is the source of truth: the docstring, __init__ and accessors are regenerated from it on the next dump.
from typing import TYPE_CHECKING... |
282c7c02563763ae17578b6c0c2caec69fdf83ada9ee7743c220aebf93095dfd | Python | 5,626 | 130 | # -*- coding: utf-8 -*-
# @title Hardware Configuration File handling class
# @file HwConfigFile.py
# @author Romain Beaubois
# @date 19 Oct 2022
# @copyright
# SPDX-FileCopyrightText: © 2022 Romain Beaubois <refbeaubois@yahoo.com>
# SPDX-License-Identifier: GPL-3.0-or-later
#
# @brief Han... |
a3421a69e1ac63521fdcd9c9679588428ab07a3fd2522f512f7710a0126f86e8 | Python | 5,626 | 131 | # -*- coding: utf-8 -*-
################################################################################
## Form generated from reading UI file 'dgn_preproc_load.ui'
##
## Created by: Qt User Interface Compiler version 6.8.0
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
##... |
d3a55867528d69ebebac3571a1af3de0e3eeb6d2cf6d20c256f9153c610238b5 | Python | 5,626 | 104 | """
Scan clustering n and saves plots dendograms, cluster seqs and assemblies for all of them
last modified: András Ecker 02.2023
"""
import os
import warnings
import numpy as np
from scipy.spatial.distance import pdist, squareform
from scipy.cluster.hierarchy import linkage, fcluster
from sklearn.metrics import davie... |
e99a5f640b01ac0f505876678c4fc74343a1dfb7dbe592023d5e381da750fe3c | Python | 5,626 | 172 | """Definitions of Edge, Vertex and Graph."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import collections
import itertools
from networkx.drawing.nx_agraph import graphviz_layout
VACANT_EDGE_ID = -1
VACANT_VERTEX_ID = -1
VACANT_EDGE_LABEL = -1
VACANT... |
fb570cfc356abb18743c0916b35d0b0e3890bfbf1f639bdd9dd77e1a38dbcc42 | Python | 5,626 | 161 | from __future__ import annotations
# MG_RESUME_CHECKPOINT_V1
from dataclasses import asdict, is_dataclass
from pathlib import Path
import hashlib
import json
def _normal(value):
if is_dataclass(value):
return _normal(asdict(value))
if isinstance(value, Path):
return str(value)
if isinsta... |
31904578d8a984e755730eb6125e5c3a6cbbea84b92d2fc0c02451fb6796463c | Python | 5,627 | 147 | from distutils.errors import DistutilsArgError
import inspect
import glob
import platform
import distutils.command.install as orig
import setuptools
from ..warnings import SetuptoolsDeprecationWarning, SetuptoolsWarning
# Prior to numpy 1.9, NumPy relies on the '_install' name, so provide it for
# now. See https://gi... |
c716442b9d48230eaf355801abea1f1404f55bf5ff8d9d51c444337696950d9b | Python | 5,627 | 164 | # Node-group asset "Symmetry Cyclic" (GeometryNodeTree), dumped by nodebpy.assets.dump_library.
# Rebuild the library with nodebpy.assets.build_library (nodebpy build).
# _build_group() is the source of truth: the docstring, __init__ and accessors are regenerated from it on the next dump.
import math
from typing import... |
c3efc82c1d1895ffcec3935d4b16aa5d3116586e0cf25625878def133966dfca | Python | 5,628 | 156 | """ParametersTab.apply_opts_dict is the inverse of registration_opts_dict (#113).
Constructs a real ParametersTab offscreen and round-trips parameter dicts.
"""
import os
import sys
PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
if PROJECT_ROOT not in sys.path:
sys.path.i... |
2e37077dd58600ebd149d29c76b89dc12687ee6502cec8ab6765b6cf6acf6ae4 | Python | 5,629 | 153 | """
Unit tests for regtools/utils/cell_utils.py
Covers:
- remove_background
- get_cell_locations
"""
import os
import tempfile
import shutil
import numpy as np
import pytest
DATA_DIR = os.path.join(os.path.dirname(__file__), "data")
# =========================================================... |
107a75b72015e7245f600c89473553a58f6e50d3166ea673e0ec1ab69e2fd4a4 | Python | 5,631 | 134 | """
This script computes the ISC maps and tests for significance according to
(Chen et al., 2016). It also performs the Mantel tests for
Chen et al., 2016. Untangling the relatedness among correlations, part I:
nonparametric approaches to inter-subject correlation analysis at the group
level. NeuroImage, 142, 248-... |
6e31ddf4e15afbef442d01c383eaf655f33b4c8590e8daf56f020080e2fe07a9 | Python | 5,631 | 152 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... |
f36f5992d60d4c008e815b98c1a55f12a95c39d680b0c579b771297d30597d83 | Python | 5,631 | 166 | from scipy import stats
import matplotlib.pyplot as plt
import numpy as np
import torch
from scipy.io import loadmat
from sklearn.model_selection import StratifiedKFold
from sklearn.model_selection import KFold
import torch.nn as nn
import torch.nn.functional as F
def train_val_test_split(kfold = 5, fold = 0):
#n... |
3932f5145de7714fb82ce4d04a395f081ddd65a5d45234ff3c85c71b027d072f | Python | 5,634 | 167 | from abc import abstractmethod
from torch.utils.data import DataLoader
from torch.utils.data.dataloader import default_collate
from utils.logger import get_logger
class BaseDatasetsManager(object):
'''
Base class for all datasets managers
'''
def __init__(self, datasets, config, collate_fn=default_col... |
9fad5c8d3f1a3e056b7d0def8af0630b0c44c05b43e970227da0703d7f3bf982 | Python | 5,634 | 133 | """Train the segmentation network (unet or MnUV3).
python -m src.train_seg --data-dir data --arch mnuv3 --epochs 300
"""
import argparse
import json
from datetime import datetime
from pathlib import Path
import albumentations as A
import numpy as np
import torch
from albumentations.pytorch import ToTensorV2
from ... |
f956d04ad8ab0acbd7b153eed30eb4185b7f7172a2c6d5e713baceaa9e6c81b4 | Python | 5,634 | 146 | import binutil
import dill
import numpy as np
import os
import time
from dreamcoder.dreamcoder import commandlineArguments, ecIterator
from dreamcoder.grammar import Grammar
from dreamcoder.domains.arc.makeTasks import get_arc_task, get_arc_tasks
from dreamcoder.domains.arc.main import MikelArcNet
from dreamcoder.doma... |
ea3d81e7767f193bb406903c61851c2091b2bdfaefaab20b8a5165762ec27642 | Python | 5,635 | 91 | """BRAIN_AUDIT.py 2026-09-29. Pre-registration: 04-NOTES/PREREG-2026-09-29n-BRAIN-AUDIT.md
Stimulate 13 sensory groups under 4 sign sets (published, undecided->inhibitory, best guess, lab prior on AL only):
does anything besides smell run away, and does a brain-wide default fix keep taste?
usage: python BRAIN_AUDIT.... |
2428ae289aa91fc3174eb63fde9183df537cc318a02bd24d43505bb06e34b956 | Python | 5,637 | 161 | import torch
from models.resnet_simclr import ResNetSimCLR
from torch.utils.tensorboard import SummaryWriter
import torch.nn.functional as F
from loss.nt_xent import NTXentLoss
import os
import shutil
import sys
apex_support = False
try:
sys.path.append('./apex')
from apex import amp
apex_support = True
e... |
af7017deb187ee9a0d2fdb111311aae10628984cc68c0db5473363b28a19e5a6 | Python | 5,637 | 168 | #!/usr/bin/env python
#
# Copyright 2009, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list... |
06d18a23e3dbe5bcde5371471c73546f90eb8d23656cf217473a2bc8766bc41f | Python | 5,638 | 177 | """Functions for generating protonation states of molecules.
Author: Seth Axen
E-mail: seth.axen@gmail.com
"""
import os
import tempfile
import subprocess
import itertools
import logging
from .util import iter_to_smiles, MolItemName
def smiles_dict_to_proto_smiles_dict(
in_smiles_dict,
max_states=3,
pka... |
9cc2e62ef3a1ceb325836158b800f699e6ce2089a79a7b63ab94a74d25e3eb94 | Python | 5,641 | 153 | import torch
import torch.nn as nn
class EEGDepthAttention(nn.Module):
def __init__(self, W, C, k=7):
super(EEGDepthAttention, self).__init__()
self.C = C
self.adaptive_pool = nn.AdaptiveAvgPool2d((1, W))
self.conv = nn.Conv2d(1,
1,
... |
9faf2d79cd1d97e1b0408b9d4a0699236461982f0f3343c89fc98269d3b13c41 | Python | 5,641 | 145 | """Structured logging facility for the registration core.
This module provides a thin wrapper over the stdlib :mod:`logging` package so
that the registration core can emit level-controlled output instead of bare
``print()`` calls, while keeping the on-console appearance byte-for-byte
identical to the old prints.
... |
f886d23c4f203af3833621b7d93fa8aa6027cada2aa068ac99774f455f5b827f | Python | 5,641 | 176 | # Node-group asset "Animate Value" (GeometryNodeTree), dumped by nodebpy.assets.dump_library.
# Rebuild the library with nodebpy.assets.build_library (nodebpy build).
# _build_group() is the source of truth: the docstring, __init__ and accessors are regenerated from it on the next dump.
from typing import TYPE_CHECKING... |
0be7db1c442f5836e34f93132db1fc45c57e2f68340b895f2943da12d3010aac | Python | 5,643 | 118 | import os
import logging
import warnings
from tqdm import tqdm
from torchdrug import data, utils
from torchdrug.core import Registry as R
from cg3_steps import cg3_protein
logger = logging.getLogger(__name__)
@R.register("datasets._3did")
class _3did(data.ProteinDataset):
def __init__(self, path, ... |
7f876a31000cf6947e328ec47224f73d996a515862be92118d2724b3b4e61061 | Python | 5,643 | 141 | import tensorflow as tf
from tensorflow.keras.layers import Dense, Layer, Concatenate, AveragePooling1D
from tensorflow.keras import Model
from tensorflow.keras.activations import sigmoid, linear
from tensorflow import transpose, matmul, expand_dims
from tensorflow import keras
from tensorflow.keras.layers import Input... |
db82b124938991c95d2d91d1ad34042c1047c6f0f499301fee10eb36d6385ea2 | Python | 5,644 | 151 | """loss functions for training"""
import torch
import torch.nn as nn
import torch.nn.functional as F
from scipy.optimize import linear_sum_assignment
from MolNexTR.tokenization import PAD_ID, MASK, MASK_ID
class GraphLoss(nn.Module):
"""
Loss function for graph-based predictions, including coordinates and edge... |
e9c723a84271f828939b573d77acadb81453ee64b98f1fa1eff7554dfbfedd68 | Python | 5,645 | 157 | """Tests for the regtools napari reader plugin (regtools.napari_plugin).
The plugin lets the standalone napari viewer (12_run_napari.bat) and every
regtools NapariViewer open NIfTI / NRRD / DICOM / VSI files - formats napari
has no built-in reader for. Tests cover the npe2 reader contract, runtime
registration o... |
00fa30a1105f8bd802b05ac7602c84ee6e652fb553c937f7f0370799d043089d | Python | 5,646 | 200 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 3 14:35:26 2022
@author: heavens
"""
import os
import numpy as np
import lmdb
import shelve
import pickle
import zlib
from abc import ABC, abstractmethod
class Database(ABC):
def __init__(self, compress = True):
self.compress = compres... |
64dfaa57da992ee0aac6c15449baa29e9ed36444b0095d19473ea01439020c8e | Python | 5,648 | 201 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... |
496ac2fc9f22e297d292c118306f96dff4ae2ed9def684c5bd146db256295668 | Python | 5,650 | 185 | # -*- coding: utf-8 -*-
"""
Created on Sat Aug 22 16:11:11 2020
@author: au571303
"""
from random import shuffle
from psychopy import prefs
prefs.hardware['audioLib'] = ['PTB']
#prefs.hardware['audioLib'] = ['pyo']
from psychopy import visual, core, sound, event, gui, logging
import os
import numpy as np
from sys impo... |
34311ae0f90f023887cb541c30c31c6dbcf5c88181846399c7d5ab398eab93ef | Python | 5,653 | 109 | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICEN... |
385a323a9d231af3355e5ec93ccaea804a79295fc34e8cd8d9250aa3bf9644eb | Python | 5,654 | 174 | """High-pass filter and locally detrend the EEG signal."""
import logging
import mne
import numpy as np
from pyprep.utils import _eeglab_create_highpass, _eeglab_fir_filter
def removeTrend(
EEG,
sample_rate,
detrendType="high pass",
detrendCutoff=1.0,
detrendChannels=None,
matlab_strict=Fals... |
0ae11dc6fe960261a76558b7802c5c3f0ac71709f5773f43cab9d4081d802da8 | Python | 5,655 | 136 | """Kim DevCCF developmental stages (E11.5 -> P14): registry wiring + the
stage-package pattern extraction (hermetic - a synthetic zip, no network)."""
import os
import zipfile
import pytest
def _dl():
return pytest.importorskip("scripts.download_devccf")
# ------------------------------------------... |
3045320c360da8bc168e26ce957a93030dc440f77cfc7dd74b0a2f82bdaa08b8 | Python | 5,655 | 169 | """
Script for filter a MbGraphMCF object by extracting a filament network
Input: - MbGraphMCF (pickle file)
- Filament network sources (slice in a XML file)
- Filament network targets (slice in a XML file)
- Filament geometrical parameters (input parameters)
Output: ... |
3f67b100af783fe517d0cbe68c0eda3865982e65485e0a749b87ae513041de6b | Python | 5,656 | 178 | """Plot performance Medication OFF vs ON."""
from __future__ import annotations
import csv
from enum import Enum
from pathlib import Path
from typing import Literal
import numpy as np
import pandas as pd
import pte_decode
import scipy.stats
from matplotlib import pyplot as plt
import motor_intention.plotting_setting... |
d2831bd6351f044458b0fb1a55738a49473de662ab7734daa070cdd2d11f54a6 | Python | 5,656 | 171 | from typing import Optional, Tuple, Dict, Any
from torch.utils.data import DataLoader, Dataset
from pytorch_lightning import LightningDataModule
import hydra
import albumentations as A
import cv2
import pli_transforms.augmentations as aug
from pli_transforms.augmentations.pytorch import ToTensorPLI
from cl_3d impor... |
0af7edc68f3b312bc3c8fe93c4d30ef345a7fde12cc731c16ab4da4dc1ff891d | Python | 5,657 | 80 | """PREDICT_TIPPING.py 2026-09-30. Pre-registration: 04-NOTES/PREREG-2026-09-30b-PREDICT-TIPPING.md
Can a connectome-only statistic of the antennal-lobe signs (share, net LN input, rho(W_EE), leading eigenvalue), fitted on
random sign sets, predict which real sign sets run away? usage: python PREDICT_TIPPING.py"""
impo... |
2b894215b523e9a9be0eee9771aef48afcfe855bbc6f9e4502f79f7eb8905516 | Python | 5,657 | 227 | import math
import matplotlib.pyplot as plt
import numpy as np
from numpy import linalg as LA
import meep as mp
resolution = 25 # pixels/μm
dpml = 1.0 # PML thickness
dsub = 3.0 # substrate thickness
dpad = 3.0 # padding between grating and PML
gp = 10.0 # grating period
gh = 0.5 # grating height
gdc = 0.5 #... |
42894efd662fb0fe75693652216343ee93d5b8bdf43004b966b0ade88741272d | Python | 5,657 | 133 | from regtools.registration.gui.batch_2d_model import BatchRow
from regtools.registration.gui.batch_2d_run import row_to_opts, build_job_batch_lines
from regtools.registration.gui.cli_args import build_registration_cli_args
def test_row_to_opts_sets_2d_fields_and_points():
row = BatchRow(
image_path... |
4396372d3589cf305b3e9bdd88ee7e7c66470241e286b7f9d730fcde0ce03f22 | Python | 5,657 | 168 | """
Script for filter a SynGraphMCF object by extracting a filament network
Input: - SynGraphMCF (pickle file)
- Filament network sources (slice in a XML file)
- Filament network targets (slice in a XML file)
- Filament geometrical parameters (input parameters)
Output... |
5ede2415f02880ec7ddbeb96f1e1afd8fcbdfd71a6c67fbd9126fdfebdccab69 | Python | 5,657 | 179 |
# imports
import numpy as np
import pandas as pd
from scipy import stats
__all__ = ['heuristic_C','filter_outliers','sort_files','transform2SD','cor_true_pred_pearson','cor_true_pred_pearson','test_cor_true_pred','prep_confs']
def heuristic_C(data_df=None):
"""
Function from Vera/Kaustubh
Calculate th... |
c45aa8d21549f1e87e8b00323b200d4bfe0a41f9e07beed073e48d47df4dec56 | Python | 5,658 | 79 |
import numpy as np
import scipy.stats
from .actflowcalc import *
from ..model_compare import *
def actflowtest(actVect_group, fcMat_group, actVect_group_test=None, print_by_condition=True, full_report=False, separate_activations_bytarget=False, transfer_func=None, avgthencomp_fixedeffects=False):
"""
Function... |
7dcf5ac5f10ee6deded981d8610db897efb365198715643948ee474ca08f1ba2 | Python | 5,659 | 147 | """Tests for regtools.registration.core.intensity preprocessing helpers."""
import numpy as np
import pytest
from regtools.registration.core.intensity import clip_normalize, histogram_match
class TestClipNormalize:
def test_outliers_clipped_and_range_0_1(self):
# One extreme outlier should not... |
07c1461ffc94c50a81a2889ebde8cbdf1880090a035c91e8e9337d7bd1b5c488 | Python | 5,660 | 109 | import argparse
import os
import h5py
import glob
import csv
import time
from datetime import datetime
import numpy as np
from skimage import measure
from scipy.ndimage import measurements
from plantsegtools.utils import H5_FORMATS
def parse():
parser = argparse.ArgumentParser(description='Process the nuclei pma... |
2d1c4f6602ce7722d54847d17ece478a94b5a668f7858387c3ed8c7a8d6a9e1d | Python | 5,661 | 175 | """
Optuna example that optimizes a neural network classifier configuration for the
MNIST dataset using Jax and Haiku.
In this example, we optimize the validation accuracy of MNIST classification using
jax nad haiku. We optimize the number of linear layers and learning rate of the optimizer.
The example code is based... |
7bad239a3946219b1ddcff9c52879bc1737450b3497ad5582b5fc0e3c1401811 | Python | 5,662 | 131 | import numpy as np
import pandas as pd
import os
import sys
import rdkit.Chem as Chem
from Bio.PDB import PDBParser, MMCIFParser, NeighborSearch
from Bio.PDB import Superimposer
from Bio.PDB import PDBIO, Select
from scipy.spatial.distance import cdist
from argparse import ArgumentParser
def get_all_non_hydrogen_a... |
96b6ad395b362ad0e8e8e98a77b4d80a3cc6176d7534381c543df58741221238 | Python | 5,663 | 140 | import torch
import torch.nn as nn
from diff_frech_mean.frechetmean import Poincare as Frechet_Poincare
from diff_frech_mean.frechetmean.frechet import frechet_mean
from diff_frech_mean.riemannian_batch_norm import RiemannianBatchNorm
# from diff_frech_mean.frechet_agg import frechet_mean
class Norm(nn.Module):
de... |
a0a3f1aaacc427909b8278d7a56e063e9367b2fd09950d8975b3305c21a3d6e2 | Python | 5,663 | 191 | #!/usr/bin/env python
# Copyright 2018, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list o... |
dca51a4e23d05eb3fa0aa5c63c8b2e3c7ee59fbd4741e77805723bdf074cec57 | Python | 5,663 | 190 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... |
2478ae3490e884c40553f53085c28765cb5ddda296e64da1459c00db50d2fd3b | Python | 5,664 | 154 | """Lasso sub-mode tests for the CCF Boundary Editor.
The lasso checkbox flips ``_select_use_lasso``; when a SELECT_DELETE
drag is committed in that mode, ``_select_drag_*`` rasterises a
polygon via ``skimage.draw.polygon`` and the unique region IDs under
it are added to (or removed from, with Ctrl) the selection ... |
98de2092115d28c24c0ca4ec0d86bcc6ccae7152af4ccd5ae119b1f1085c6e70 | Python | 5,664 | 163 | from ._base import EncoderMixin
from timm.models.resnet import ResNet
from timm.models.res2net import Bottle2neck
import torch.nn as nn
class Res2NetEncoder(ResNet, EncoderMixin):
def __init__(self, out_channels, depth=5, **kwargs):
super().__init__(**kwargs)
self._depth = depth
self._out_... |
7bbe6936bb8a2713a2747560bb69dad4036072ac43357608670e4072db63659e | Python | 5,665 | 148 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... |
9f7a3fd995136785d43c21ef823a9182103d4ee352b0dcae3d2d63988dd88029 | Python | 5,665 | 188 | """Common elastic constants workflows."""
from __future__ import annotations
from typing import TYPE_CHECKING
from ase import units
from ase.stress import voigt_6_to_full_3x3_stress
from emmet.core.elasticity import ElasticityDoc
from pymatgen.analysis.elasticity.stress import Stress
from pymatgen.io.ase import AseA... |
82c8c29391239c75076e2fbb60500674a4972c70dfa3c7962e4070f0bdd1a328 | Python | 5,666 | 184 | # -*- coding: utf-8 -*-
def _cell_dat_indexer(files):
if isinstance(files['cell_dat'], str):
return [files['cell_dat']]
else:
return files['cell_dat']
def _cell_dat_loader(index):
import numpy as np
return {'cell': np.loadtxt(index, usecols=(1,2,3))}
def _stress_indexer(files):
im... |
485041a9466795aa307c59d408521ffafc097978113194518bcfe2eb17faf330 | Python | 5,668 | 162 | import matplotlib.pyplot as plt
import numpy as np
colors = ["red", "blue", "green", "orange"]
def plot_oc_singlenode(
duration,
dt,
state,
target,
control,
orig_input,
cost_array=(),
plot_state_vars=[0, 1],
plot_control_vars=[0, 1],
):
"""Plot target and controlled dynamics f... |
a4014b4c977e8ec5515cb2f58f2848d394fab0799286fa9c0b71fc904a9a34a4 | Python | 5,668 | 170 | from abc import abstractmethod
from collections.abc import Iterable
from typing import override
import torch
import torch.nn
from elasticai.creator_plugins.lutron_filter.precompute.lutron_filter import (
LutronLinear,
LutronMaxPool,
)
from elasticai.creator_plugins.lutron_filter.precompute.lutron_module_protoc... |
cdd071981197c39a22f05303a7ababa472765f31a46754a7029a02605f2f7309 | Python | 5,668 | 153 | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.distributions import Normal
from torch.optim import Adam
from collections import deque, namedtuple
import copy
from .replay_memory import ReplayMemory
from .replay_memory import HerReplayMemory
from .gaussianpoli... |
ea39d429d02a9726d8c2abf7295afcbd56e944b134e7655152074895a287c600 | Python | 5,668 | 164 | #!/usr/bin/env python
from __future__ import print_function
import numpy as np
from examples.continuous_tamp.primitives import get_pose_gen, inverse_kin_fn, get_region_test, plan_motion, \
tight, blocked, draw_state, get_random_seed, TAMPState, GROUND_NAME, GRASP, SUCTION_HEIGHT, apply_action
from examples.conti... |
478078f1c17adddd12144cd2ffed2688ce933848fc6b03796fce3286b7befaa0 | Python | 5,669 | 127 | # Taku Ito
# 07/14/2017
##Modified by MWC June 20, 2017
##Modified by TI June 20, 2017
##Modified by MWC November 9, 2019
# Code to perform permutation testing to control for family-wise error (FWE)
# Using max-T approach as described in Nichols & Holmes (2002)
# Nichols TE, Holmes AP. (2002). Nonparametric permutatio... |
4c6c35e494957577e717b8438a31329190240f82eb2c2aec11a8f8710b07cd10 | Python | 5,670 | 130 | import os
import random
from time import time
import pandas as pd
import numpy as np
import networkx as nx
import argparse
import pickle
from utils.utils import *
from utils.graph_creation import *
from utils.motif_counts import *
from utils.visualization import *
import graph_tool.all as gt
sns.set_context("talk")
... |
54837f41d6579cccc91eae2929aff91d9ea94ed2cdd65e8af25d170bb77faa59 | Python | 5,670 | 154 | # -*- coding: utf-8 -*-
"""
Created on Tue Apr 13 18:41:38 2021
@author: divyoj
"""
import numpy as np
import pickle as pkl
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import matplotlib as mpl
from matplotlib import rc
#rc('font',**{'family':'serif','serif':['Computer Modern Roman']})
## for Palatino... |
f33a7d92c7ea529c14674fb2f43d88793f8939b8e814b530e15c1e7c49345f3c | Python | 5,670 | 167 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... |
86b30987af7a288086ceba79a057809c0f159f9aca368cb5758ba0c26a57b832 | Python | 5,671 | 171 | # MIT License
# Copyright (c) 2023 Qiyun Wu
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge... |
efc67b82fc47f983afab966366516d1f08018de65debf012b9ddaa564010d2f8 | Python | 5,671 | 148 | # -*- coding: utf-8 -*-
import tensorflow as tf
from .. import _logging as logging
from .core import *
__all__ = [
'ConcatLayer',
'ElementwiseLayer',
]
class ConcatLayer(Layer):
"""A layer that concats multiple tensors according to given axis..
Parameters
----------
layers : list of :class... |
1415e8728c7d6e5a42426674b18f55843f3a29f4d43e041e00bfd35121965eec | Python | 5,678 | 138 | import math
import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
from typing import *
from models.model import Model
from models.kan_layers import KAN
class M1DCNN_KAN_Net(nn.Module):
@staticmethod
def weight_init(m):
if isinstance(m, nn.Linear) or isinstance(m, nn.Conv1... |
c57c3fd58e9b09c5771befa464a7de5750fba3830e0f5ab79658804a88e73079 | Python | 5,680 | 149 | # Copyright (c) 2022, Ko Sugawara
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and t... |
fca90b06a59c6bf7124e7cef3676a9044f0bbf37d244732ca38b37840c397c23 | Python | 5,680 | 182 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... |
1d347f8bebd16adb81bb358776efafdc5bb2d8b72cdcad2537321466b45d3eff | Python | 5,681 | 154 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@author: A.Akdogan
"""
import os
from dataset_builder import NailDataset
import segmentation_models_pytorch as smp
from utils import *
from helper import utils
from torch.utils.data import DataLoader
import torch
import warnings
import pickle
import json
warnings.fil... |
f651ecd11c379301fdafdd87661dbaf3fd43c67d5eb17f395108dda13e76c1f7 | Python | 5,681 | 127 | import torch
import torch.nn as nn
class Conv2dWithConstraint(nn.Conv2d):
def __init__(self, *args, max_norm: int = 1, **kwargs):
self.max_norm = max_norm
super(Conv2dWithConstraint, self).__init__(*args, **kwargs)
def forward(self, x: torch.Tensor) -> torch.Tensor:
self.weight.data =... |
a3182ca08471b7e65e57367a7038a2d28423d101928f229c868da3b4e5135866 | Python | 5,682 | 161 | from __future__ import print_function
import numpy as np
import math
from .viewer import sample_box, is_collision_free, \
create_box, draw_environment, point_collides, sample_line, add_points, \
add_roadmap, get_box_center, add_path, get_distance_fn
from ..utils import user_input, profiler, INF, compute_path_... |
a41fc91398bd607df9f32d9b5030ddea890783fc7bacaa43453f864b293954ce | Python | 5,682 | 165 | from datetime import datetime
from numpy import c_, nan, empty, memmap, float64
from pathlib import Path
from scipy.io import loadmat
from .utils import (read_hdf5_str,
read_hdf5_chan_name,
DEFAULT_DATETIME,
)
from ..utils import MissingDependency
try:
f... |
9b07ef60710d8e8e9c3757b642e3e35cab7dfae495823a3d12ea465ad633ff9e | Python | 5,686 | 174 | """Each encoder should have following attributes and methods and be inherited from `_base.EncoderMixin`
Attributes:
_out_channels (list of int): specify number of channels for each encoder feature tensor
_depth (int): specify number of stages in decoder (in other words number of downsampling operations)
_... |
3a5c52fe2eeba4aab87cb5178e11a54a9c5e2ddd654a56264387a96176c9607f | Python | 5,687 | 164 | # -*- coding: utf-8 -*-
from __future__ import print_function
import itertools
class NegativeClause(object):
# disjunction of inequalities
def __init__(self, parts):
self.parts = parts
assert len(parts)
def __str__(self):
disj = " or ".join(["(%s != %s)" % (v1, v2)
... |
79c582e9dbdfd03db86ae234de01b66caf5e7c976b659ae3d11c2825bfd2b0ae | Python | 5,687 | 123 | import os.path
import gzip
import csv
from ckg.graphdb_builder import mapping as mp, builder_utils
def parser(databases_directory, importDirectory, drug_source=None, download=True, db="STRING"):
config = builder_utils.get_config(config_name="stringConfig.yml", data_type='databases')
mapping = mp.getSTRINGMapp... |
d33e88b28bed04cc632501d2e1c46516b3584de6f94e4ee2a14d73d7923245eb | Python | 5,687 | 120 | from __future__ import print_function
from pddlstream.utils import INF, elapsed_time, find, user_input, Verbose, str_from_object
from pddlstream.algorithms.algorithm import parse_problem
from pddlstream.algorithms.focused import solve_focused
from pddlstream.language.conversion import Certificate, Object, \
obj_fr... |
d856bcb17288946b0a2da7584caf13ea970e3bb451ade841f31f4e27f6ed8772 | Python | 5,687 | 121 | from __future__ import annotations
import re
from typing import Any
from wikibaseintegrator.datatypes.basedatatype import BaseDataType
from wikibaseintegrator.models import Claim
from wikibaseintegrator.wbi_config import config
from wikibaseintegrator.wbi_enums import WikibaseSnakType
class GlobeCoordina... |
ed064ba0404c68e4239bc13273343c635149f3dd6634814e9240b52cf7283e94 | Python | 5,687 | 179 | # Node-group asset "Random Color" (GeometryNodeTree), dumped by nodebpy.assets.dump_library.
# Rebuild the library with nodebpy.assets.build_library (nodebpy build).
# _build_group() is the source of truth: the docstring, __init__ and accessors are regenerated from it on the next dump.
import math
from typing import TY... |
f00a2bb5f9da4f618178a5b1e8b9e4998c9c7ce0f234b5649f608291f8301d9a | Python | 5,687 | 157 | """Implementation of CLI modify command."""
import math
from itertools import chain
import numpy as np
from treem.morph import Morph
from treem.io import SWC
from treem.utils.geom import rotation
def modify(args):
"""Modifies selected parts of morphology reconstruction."""
# pylint: disable=too-many-local... |
0355e6af493a332d22d426ae5eac7c4377a4c8b11389926f73e5a57e0ae8ca5d | Python | 5,688 | 174 | """
Inward rectification by CP-AMPARs
"""
import os
import numpy as np
import matplotlib.pyplot as plt
import cmasher as cmr # colormap
import seaborn as sns
import pandas as pd
from src.constants import pink, green
from src.metrics import compute_osi
from src.simulation import simulate_with_conductance, weight_scale
... |
3a2b5367ef3260047972052555666721d1a76060169245ab53d39cb7843aa486 | Python | 5,689 | 136 | import math
from collections import defaultdict
import torch
from torch import nn
from torch.nn import functional as F
from torch.utils import data as torch_data
from torchdrug import core, tasks, layers
from torchdrug.layers import functional
from torchdrug.core import Registry as R
@R.register("tasks.BindingAffin... |
9ba0e866266279ed0dd94af0430bd3415f5a69411ddded51235f6f44d2345d08 | Python | 5,690 | 164 | import math
import torch
from torch import nn
from torch.nn import init
def init_weights(net, init_type='normal'):
# print('initialization method [%s]' % init_type)
if init_type == 'kaiming':
net.apply(weights_init_kaiming)
else:
raise NotImplementedError('initialization method [%s] is no... |
b7aee1c474fb99536d7894ff5d067774b799577414f1e6b1f700f4f2fa076be7 | Python | 5,690 | 197 | import xgboost as xgb
import numpy as np
from xgboost import XGBClassifier
from sklearn.model_selection import GridSearchCV
import gc
import argparse
import os
import struct
from ctypes import cdll
from ctypes import c_float, c_uint, c_char_p, c_bool
# function to allow xgboost model to be used in rust with gbdt-rs
# ... |
170201df0b66a4144bf217a31a1ede95e72299b07caad080b38c2b62fd411c7a | Python | 5,691 | 161 | """
(*)~---------------------------------------------------------------------------
Pupil - eye tracking platform
Copyright (C) 2012-2020 Pupil Labs
Distributed under the terms of the GNU
Lesser General Public License (LGPL v3.0).
See COPYING and COPYING.LESSER for license details.
------------------------------------... |
9853217fa9555ba249e34fe033c9ccd57051ab6d833e3715e169ccf36ce36a0c | Python | 5,691 | 172 | """Plot earliest prediction timepoints."""
from __future__ import annotations
import csv
from enum import Enum
from pathlib import Path
import numpy as np
import pandas as pd
import pte_decode
import scipy.stats
from matplotlib import pyplot as plt
import motor_intention.plotting_settings
import motor_intention.proj... |
08a48cf106882234770fef2b1c58a19aee79b1c3771107c633124545fa7bd6fb | Python | 5,692 | 127 | import os
import tempfile
import unittest
from torcheeg.model_selection import KFoldPerSubjectCrossTrial, KFoldPerSubjectGroupbyTrial, train_test_split_per_subject_cross_trial, train_test_split_per_subject_groupby_trial
from .test_utils import _make_dataset
class TestPerSubjectSplits(unittest.TestCase):
def se... |
549e0d127b95840adbf3de147d51ce574a6c1f72cd11a24a7153b7c6f927d8dd | Python | 5,692 | 173 | """Tests for regtools.registration.napari_launchers: the standalone
view_output_napari.bat / view_input_napari.bat polyglot launchers written into
a registration run's output folder.
Each .bat is a polyglot - line 1 is a batch header that re-invokes the venv
python on the file with ``-x`` (skip first line), lines... |
5b91c2491087b329d6fbffe3a94da266afee0f03655fda2de86c8c091e43f659 | Python | 5,692 | 135 | from typing import Tuple
import torch
import torch.nn as nn
class InceptionConv2d(nn.Module):
def __init__(self, in_channels: int, out_channels: int, bias: bool = True):
super().__init__()
self.conv5x5 = nn.Conv2d(in_channels, out_channels, kernel_size=5, stride=1, padding=2, bias=bias)
s... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.