sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
f5f9a9a2bf6e3a86182604265fa1d0a1806aed65b4bc0dbe7a05abbcff3d4a68 | Python | 5,995 | 152 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
from __future__ import annotations
from pathlib import Path
from ultralytics.utils import LOGGER, SETTINGS, TESTS_RUNNING
try:
assert not TESTS_RUNNING # do not log pytest
assert SETTINGS["clearml"] is True # verify integration is enabled... |
5c235830ad52224fe6f5c363127575d7d7ef8a7b6dd80ac3a6d087633be23b37 | Python | 5,998 | 198 | """
Visualization helpers: ROC / PR curves for 8-label classifier
and box plots of regression residuals.
All plots use Matplotlib (Agg backend) and save PNG
to `results/figs/`.
Example
-------
>>> from src.utils.plot_utils import plot_multilabel_roc
>>> plot_multilabel_roc(y_true, y_prob, "results/figs/roc.png")
"""
... |
cce62c8fedef5d59c67753a5d9baaff2c944ba381f43a6ea7b2846e81023a39d | Python | 5,999 | 141 | import os
import time
import torch
import argparse
from torch.utils.data import DataLoader
from model.sphereglue import SphereGlue
from utils.demo_mydataset import MyDataset
import numpy
from utils.Utils import draw_match, split_name
torch.cuda.empty_cache()
torch.manual_seed(1)
if __name__ == '__main__':
parse... |
d178e73d0ea74e9d94d792424429b5517a15ed5353040c0f6a16572431be3328 | Python | 6,004 | 126 | from typing import List, Tuple
import dgl
import numpy as np
import pandas as pd
import torch
from dgl.nn.pytorch import pairwise_squared_distance
from torch import FloatTensor
from utils.deepinteract_constants import DEFAULT_MISSING_HSAAC, HSAAC_DIM
try:
from types import SliceType
except ImportError:
Slice... |
ee9cabe662b6264113dea5a212a2e4557663fc3f31a886dc46eabb10baac2551 | Python | 6,004 | 162 | import random
from analognasbench.data import AnalogNASBench, DriftMeasurement
def evaluate_fitness(benchmark, arch, metric='analog_drift_86400'):
"""
Returns the drift value of the specified architecture for the given metric.
If it's not found, returns -inf to effectively invalidate the architecture.
... |
a8973244c8e4080bd6f8c52d980cfec7cc0975098587109aecef85a6b10e98d1 | Python | 6,005 | 135 | """Post-stim activity feature matrices + stimulation-pattern decoding.
Port of the ``stimActivityStore`` construction and the ``fitcecoc``-based
pattern-decoding block of ``stimActivityAnalysis.m`` (origin/main).
**Stochastic + degenerate on the test data.** MATLAB decodes *which pattern* was
stimulated from post-sti... |
e9c6da260c648dcb05461971c40a92354e1f65641566f62b65757b6286ed98f7 | Python | 6,005 | 151 | # This file is part of connectome-manipulator.
#
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2024 Blue Brain Project/EPFL
"""Module for comparing connectomes based on adjacency matrices:
Structural comparison of two connectomes in terms of adjacency matrices for selected pathways
(including synapse counts p... |
b3d04f347e6c5c967844268bbff465ae39c18e7c22b2ece17c63f2b6576b0ccc | Python | 6,006 | 160 | #!/usr/bin/env python3
import os
import glob
import json
import nibabel as nib
import shutil
import numpy as np
from tqdm import tqdm
from src.wrappers.OsipiBase import OsipiBase
# --------------------- Helper Functions --------------------- #
def read_nifti_file(input_file):
nifti_img = nib.load(input_file)
... |
6bedeadc9cea376ff8784897525fa35d44980bd05e9337a15c4f1e0100fa14f8 | Python | 6,007 | 205 | #!/usr/bin/env python3
import os
from typing import Optional, Tuple
import numpy as np
import nibabel as nib
import matplotlib.pyplot as plt
def find_best_slice(mask_3d: np.ndarray, axis: int = 2) -> int:
counts = []
for i in range(mask_3d.shape[axis]):
if axis == 0:
sl = mask_3d[i, :, :... |
8a248c627b4869a654167185ad830111a6ab170f4bdc38375d0d600ab2c32ca2 | Python | 6,007 | 148 | #!/usr/bin/env python
"""
Handles mosaic related functionality.
Responsibilities:
1. Keep track of the current objective.
2. Output the pixel to nanometer scaling given the current
objective.
Hazen 01/17
"""
from PyQt5 import QtWidgets
import storm_control.hal4000.halLib.halMessage as halMessage
import sto... |
4cc63e2a8e08f8c38e1b3eba9136811056f80d54679912a2c8ed4bc0656dbaea | Python | 6,008 | 168 | from pathlib import Path
from templateflow import api as tflow
import os
def get_reference(wf, ref_type=None, ref_path=None, allow_fsl_fallbacks=False):
"""
Retrieves the reference path based on the provided type or path.
Parameters:
wf (object): The workflow object.
ref_type (str, option... |
9b331bbe337e31f772e494e7603bffced721c026fb57d736a9346f8a8f6e8dee | Python | 6,008 | 183 | from data_utils import get_cropped_image, write_to_json
from tqdm import tqdm
from typing import List, Dict, Tuple
from warp import ImageWarper
import glob
import h5py
import json
import nibabel as nib
import numpy as np
import os
class ROIWarper(ImageWarper):
def __init__(self, *args, **kwargs):
super(... |
a9cd2f3ee3f48d8eba8c2af0276767e02f8b4b47ca11c804180b664e57b3ab43 | Python | 6,008 | 118 | import pickle as pkl
import numpy as np
import argparse
from system import System
from tqdm import tqdm
import os
from joblib import Parallel, delayed
parser = argparse.ArgumentParser()
parser.add_argument('--simulation', type=str, default='charged',
help='What simulation to generate.')
parser.add... |
49d6289548fad9e1c39e7ea03be2eebe4b96eaf06bd40db905febdb52900cf49 | Python | 6,009 | 170 | from collections.abc import Sequence
from typing import Any
from fastapi import FastAPI
from eir.predict_modules.predict_tabular_input_setup import (
ComputedPredictTabularInputInfo,
)
from eir.serve_modules.serve_api_models import ResponseModel, create_input_model
from eir.serve_modules.serve_experiment_io impor... |
a01e823f2b5abed5a0e6300bf1f6d1a33dc0137da2dae5815fdeab7767299082 | Python | 6,011 | 203 | """Miscellaneous utilities for manipulating NumPy ndarrays."""
import numpy as np
from numba import njit
# Based on solution by:
# user48956
# https://stackoverflow.com/questions/911871/detect-if-a-numpy-array-contains-at-least-one-non-numeric-value
@njit(nogil=True)
def one_or_more_nan(array):
"""True if an arr... |
34936e535ce1378e202a5d996f6f49dd69c031721b9bc140ca54710f28a5280b | Python | 6,012 | 203 | #!/usr/bin/python
#
## @file
#
# A wheel widget for controling things like the microscope focus motor.
#
# Hazen 11/13
#
from PyQt5 import QtCore, QtGui, QtWidgets
import sys
## QAbstractWheel
#
# Wheel super class.
#
class QAbstractWheel(QtWidgets.QWidget):
valueChanged = QtCore.pyqtSignal(float... |
73faa70fea3dfaa31afaf68e8040c66f9653d4d7614b6beb85341da7ef1c608a | Python | 6,013 | 165 | from math import ceil
from typing import Optional
import torch
from torch import Tensor
from torch.nn import ELU
from torch.nn import BatchNorm1d as BN
from torch.nn import Conv1d
from torch.nn import Linear as L
from torch.nn import Sequential as S
import torch_geometric.typing
from torch_geometric.nn import Reshape... |
e8348a8fbc8ba44a7efc0516e4a8524a19b65a037c37e4417371014b83d4c68c | Python | 6,013 | 164 | """Abstract base classes for execution backends.
This module defines the ``ExecutionBackend`` protocol and the ``TaskSpec``
data model that all workflow managers (Parsl, EnsembleLauncher, local
process pool, etc.) must implement. Downstream code (MCP servers, tools)
only depends on these abstractions -- never on a co... |
7f3a521790863762af662ed0b59d1c642f74d7ee646f91b755e6e66497790334 | Python | 6,014 | 186 | # -*- coding: utf-8 -*-
"""
Gene developmental expression matrix creation for the zebrafish analysis.
Lange et al. data (2024)
"""
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... |
99ebfe006a7137e6031cde7fa5789c1cbd57fd91779f14f0d8796d177fa6a877 | Python | 6,015 | 161 | # Copyright (C) 2021-2022 Intel Corporation
# Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import json
from http import HTTPStatus
import pytest
from cvat_sdk.api_client.api_client import ApiClient, Endpoint
from deepdiff import DeepDiff
from shared.utils.config import get_paginated_collection,... |
d990257a8a497c9ae7db6ae3307fea2b95bc2e24573c0a74a49c7c36f35dfa13 | Python | 6,015 | 169 | # command line
from nipype.interfaces.base import CommandLine
from nipype.interfaces.base import CommandLineInputSpec, File
from nipype.interfaces.base import TraitedSpec, traits
from nipype.interfaces.utility import Function
from nipype.interfaces.base import BaseInterface, BaseInterfaceInputSpec
import re
import niba... |
b6f19a6c54ddba0c126b7607e1de65c57ede0c16cb40db352154601c78c695bd | Python | 6,016 | 172 | """A wrapper around the tqdm.tqdm iterator that adds a ProgressBar to a magicgui."""
from __future__ import annotations
import contextlib
import inspect
from typing import TYPE_CHECKING, Any, cast
from magicgui.application import use_app
from magicgui.widgets import FunctionGui, ProgressBar
if TYPE_CHECKING:
fr... |
63db9887caefa2e5f80615e0a5c86d19d88ed02850b313e291dfc8c73f9b357c | Python | 6,017 | 144 | import torch
import torchvision.transforms.functional as ttf
from torch import Tensor
from yacs.config import CfgNode
from typing import Dict, Optional
@torch.no_grad()
@torch.jit.ignore()
def transform_from_cfg(data_dict: Dict[str, Tensor],
cfg: CfgNode,
device: Optional... |
df1774240185914baa050cf00a4a56c8a2ec254e4aa896cb34da373339c5c3da | Python | 6,017 | 126 | from typing import List, Tuple
import dgl
import numpy as np
import pandas as pd
import torch
from dgl.nn.pytorch import pairwise_squared_distance
from torch import FloatTensor
from project.utils.deepinteract_constants import DEFAULT_MISSING_HSAAC, HSAAC_DIM
try:
from types import SliceType
except ImportError:
... |
c61f76aee5495b7ea2c505e7b08101c177e967da09bfa3f41b905f17e24df24b | Python | 6,018 | 126 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
import math
from typing import Any
import cv2
from ultralytics.solutions.solutions import BaseSolution, SolutionAnnotator, SolutionResults
from ultralytics.utils.plotting import colors
class DistanceCalculation(BaseSolution):
"""A class to cal... |
06e94fa63c9042e5a6c63e88ada618392cc1e510322bcee50999a6b8c58b680e | Python | 6,020 | 255 | # -*- coding: utf-8 -*-
"""
Created on Fri Aug 18 18:23:26 2023
@author: DELINTE Nicolas
"""
from scipy.sparse.csgraph import shortest_path
import numpy as np
from tqdm import tqdm
from itertools import combinations
from unravel.core import get_microstructure_map, get_weighted_mean
def get_metric_along_trajectory(f... |
5c04fc627b4c21f44b91f66be16c423f4834768890a36be66a3ce9f7c99b93fe | Python | 6,020 | 113 | """A module that contains processors for computing affinity, i.e., similarity, matrices for sets of measurements."""
import typing
from typing import Annotated
import numpy
import scipy.sparse
from corelay.base import Param
from corelay.processor.base import Processor
class Affinity(Processor):
"""The abstract... |
a204a85b6249abd6db44e9dfe326c7a794a6032bf2232fc17cc34210bd5c27e9 | Python | 6,022 | 154 | """ Normalization layers and wrappers
Norm layer definitions that support fast norm and consistent channel arg order (always first arg).
Hacked together by / Copyright 2022 Ross Wightman
"""
import numbers
from typing import Tuple
import torch
import torch.nn as nn
import torch.nn.functional as F
from .fast_norm im... |
56fbd373c6408f69dc471ef8fa42e249217b59691ce2c5405f3ce82e109c8195 | Python | 6,023 | 153 | import numpy as np
from sklearn.metrics import roc_curve, auc
from scipy.spatial.distance import pdist, squareform
from sklearn.metrics.pairwise import cosine_similarity
def compute_correlation_with_stimuli(ensembles_timecourse, data_stims):
"""
Compute Pearson correlations between ensemble timecourses and st... |
05d7e899c19e27c44ea44581a2cf97babba7b0c215d76a6cbe8356e4b750ac62 | Python | 6,024 | 165 | # -*- coding: utf-8 -*-
"""
Recursive Boundary-Based Registration
This script performs recurive BBR to register a functional data set with
surfaces generated from a separate whole-brain anatomy.
parameter mode (explanation from one of Tim vanMourik's scripts):
`r' for rotation around all axes, `rx', `ry', or `rz' for... |
4cc6abe17fadffefbe7a57cb579093807a57a0fb82c548a44a3a013b70b3d6a2 | Python | 6,026 | 174 | from experimental_run import ExperimentalRun
from psychopy import visual, event, core, monitors
import numpy as np
from const import (
STIMULUS_COORDINATES,
FOVEAL_COORDINATES,
TRIGGER_KEY,
START_KEY,
CONDITION_TEXT,
CONTROL_TEXT,
FULLSCREEN,
STIMULUS_SIZE,
STIMULUS_DIR,
SCREEN,
... |
ee83ddf996af1fb3cda4e6b9e4fa910383f914b9ce78e0693f3d59c530f8d9b0 | Python | 6,026 | 126 | import numpy as np
import pandas as pd
from snakemake.io import expand
from drop import utils
from .Submodules import Submodule
class AS(Submodule):
def __init__(self, config, sampleAnnotation, processedDataDir, processedResultsDir, workDir):
super().__init__(config, sampleAnnotation, processedDataDir,... |
9e3976403a7148e0cf8bcf164eee1ee1a699e88e25ce066b75234f4f843b531a | Python | 6,027 | 166 | # -*- coding: utf-8 -*-
"""
Created on Tue Mar 9 13:17:30 2021
@author: Yoshi
"""
import warnings
warnings.simplefilter(action="ignore",category=FutureWarning)
import os
import shutil
import cv2
import numpy as np
import matplotlib.image as mpimg
import imageio
import caiman
from caiman.motion_correction import Mot... |
8b5884067972ed270f7c5a170226de40cdc775fc76c9b53d8c20cf478729d9b2 | Python | 6,028 | 164 | """KFold validation, adapted from `https://github.com/Lightning-AI/lightning/blob/master/examples/pl_loops/kfold.py`_"""
from abc import ABC, abstractmethod
from copy import deepcopy
import os
from pathlib import Path
from typing import Any, Dict, List, Tuple, Type
from pytorch_lightning import LightningDataModule, Li... |
00c0484102199aa36c3501058874e3743ccfd087a91c9a15efe2dd7afa9a32a7 | Python | 6,029 | 108 | # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file '/media/lg/disk2/PycharmProjects/ISAT_with_segment_anything/ISAT/ui/auto_segment.ui'
#
# Created by: PyQt5 UI code generator 5.15.10
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this ... |
6f84a585e8aa75014269312900793d993e28fd99f9bba04b2d7e29aa68384d0f | Python | 6,030 | 151 | import torch
from nnunetv2.training.loss.dice import SoftDiceLoss, MemoryEfficientSoftDiceLoss
from nnunetv2.training.loss.robust_ce_loss import RobustCrossEntropyLoss, TopKLoss, RobustCrossEntropyLoss_Weighted
from nnunetv2.utilities.helpers import softmax_helper_dim1
from torch import nn
class DC_and_CE_loss(nn.Mod... |
00ff43995d5686756870878167034801937fd72ac4718eb78a550169ad2e22eb | Python | 6,031 | 175 | import os
from datetime import datetime
import logging
import argparse
import yaml
import jinja2
from jinja2 import meta
import easydict
import torch
from torch.utils import data as torch_data
from torch import distributed as dist
from torchdrug import core, utils
from torchdrug.utils import comm
logger = logging.... |
ed3aa212f37f85e8168461bb821f93f516d98e1ada4e6fe2e9f098d9165ea5ad | Python | 6,031 | 207 | import multiprocessing
import os
import uuid
import h5py
import numpy as np
import pytest
pytest.importorskip("PySide6")
from musclex.ui.xv_single_instance import (
PROTOCOL_VERSION,
XVProtocolError,
XVSingleInstance,
_open_in_viewer,
_validate_viewer_request,
decode_message,
encode_messa... |
38a8d8b4d8aad10584263499c19456fb0e6880c22ce9279c4f5ba4408b34df06 | Python | 6,032 | 160 | import numpy as np
import rastermap.utils
from matplotlib.axes import Axes
from rastermap import Rastermap
from scipy.stats import zscore
from argclz import AbstractParser
from neuralib.persistence.cli_persistence import get_options_and_cache
from neuralib.plot import plot_figure, ax_merge
from neuralib.rastermap impo... |
e866f4630a89ff065e58710aa95c53e5f29ccb5902b2a7166cec0170903558e7 | Python | 6,032 | 177 | #!/usr/bin/python3
#
import os
import sys
import argparse
import shutil
import numpy as np
from sklearn.neighbors import NearestNeighbors
from uac import utils
# Create the parser
my_parser = argparse.ArgumentParser(description="UAC fibre mapping")
# Add the arguments
my_parser.add_argument("target_path", metavar="p... |
ed8dbb181e391d17426422be041fa9eedc9353ce6407e8e203fa4e3df132ec25 | Python | 6,033 | 169 | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import copy
import os
import os.path as osp
import time
import mmcv
import torch
from mmcv.runner import init_dist
from mmcv.utils import Config, DictAction, get_git_hash
from depth import __version__
from depth.apis import set_random_seed, train_depther... |
666d82dbd24f7d85f2c3a727cd99d5159ef2be5bddcdcb9f5ce181202c1b8ba9 | Python | 6,034 | 204 | import re
from functools import partial
def _split_tokenizer(x): # noqa: F821
# type: (str) -> list[str]
return x.split()
def _spacy_tokenize(x, spacy):
return [tok.text for tok in spacy.tokenizer(x)]
_patterns = [
r"\'",
r"\"",
r"\.",
r"<br \/>",
r",",
r"\(",
r"\)",
r... |
4afaca92a5bed546c75a8c2a2c0f12553879d59c25c0dfe37ac05de292d9c549 | Python | 6,035 | 189 | #!/usr/bin/env python3
"""
Fast MRI face voxelator for deidentifying T1w and T2w structural images
Authors
----
Mike Tyszka, Caltech Brain Imaging Center
MIT License
Copyright (c) 2021 Mike Tyszka
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentat... |
595cb5fb8292c5ea848828b4101282e3407ea5c9e99974ebe09bdddcfbdf82a8 | Python | 6,035 | 197 | import os
import os.path as op
import nibabel as nib
import numpy as np
from dipy.reconst import dti
from scipy.special import gamma
import AFQ.utils.models as ut
__all__ = ["fit_dti", "predict"]
def noise_from_b0(data, gtab, bvals, mask=None, b0_threshold=50):
"""
Coped from vistasoft's dtiComputeImageNoi... |
d8c0cf810dfdc007fb36a2e12e863f645e95e4558e5ad282fc9f423f39bb7f41 | Python | 6,039 | 199 | """MLP evaluator."""
import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
from torch.utils.data import DataLoader, TensorDataset
from sklearn.preprocessing import StandardScaler
from analognas.evaluators import Evaluator
from analognas.utils import accuracy_mse
device = 'cuda' if torch.cud... |
b28d60d610e34fff0fde1216802d3c06d75892016fc027c3fabfc47ff5040bee | Python | 6,040 | 159 | from pathlib import Path
from unittest.mock import Mock, patch
import pytest
from brainways.project.info_classes import (
MaskFileFormat,
RegisteredPixelValues,
SliceSelection,
)
from brainways.ui.widgets.analysis_widget import AnalysisWidget
@pytest.fixture
def mock_controller():
controller = Mock(... |
3b65d8ba84e53fd6d8ff0a2dbf2a9ae73ff8705ca443182299ed0965ee43eec3 | Python | 6,041 | 140 | #! /usr/bin/env python
"""Step one of the pipeline for surface morphometrics
Convert a semantic segmentation MRC file to a series of membrane meshes for each segment.
Takes a label MRC file and outputs a point cloud xyz file, a mesh ply file, and a mesh vtp file.
Uses a config yml file to configure the conversion proce... |
c5fb730d42fca331946f9024a621a40751c4a64d65877c271d556eab7d6c7d8c | Python | 6,041 | 155 | import os
import subprocess
import logging
from util.io import make_dir_if_not_exists, create_logger
from util.config_vars import config
class Defacing:
"""Executes the defacing of an MRI NIfTI from a given file path.
Defacing methods: pydeface, mri_deface, quickshear, fsl_deface.
"""
def __init__(se... |
40f9e0a423007a43978df28bcb92cb77aeef76579017bb4d6963c01f6556a42e | Python | 6,042 | 198 | """
Copyright 1999 Illinois Institute of Technology
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, publis... |
fb27abe043ec2ad47b2880a006119107efe3e19d8a15976a1b9aa86ffe9c53f5 | Python | 6,042 | 284 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Fit FLIM data
"""
import os
import mbflim.utils as ut
import mbflim.parameters as par
import tools.flim.flim_set_processing as fl_setpro
import tools.flim.flim_visualization as fl_vis
#%% Parameters
# Parallelism
PROCESS_NB = 16
MAX_THREAD_NB = 32
#%% Fixed param... |
0303b135f3954ac29f07a37bfec1c3fd3ebda84f4c921772e80a481fa548fcc5 | Python | 6,045 | 284 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Fit FLIM data
"""
import os
import mbflim.utils as ut
import mbflim.parameters as par
import tools.flim.flim_set_processing as fl_setpro
import tools.flim.flim_visualization as fl_vis
#%% Parameters
# Parallelism
PROCESS_NB = 16
MAX_THREAD_NB = 32
#%% Fixed param... |
8cb4913e9c2f1fd8251e28ce8d818971f408fd34ebea5bd45f8a4d467666dc73 | Python | 6,045 | 177 | import argparse
import os
import os.path as osp
import time
import numpy as np
import torch
import torch.nn.functional as F
from sklearn.metrics import f1_score
import pandas
import json
import torch_geometric.transforms as T
from tqdm import tqdm
import spacy
import re
import ijson
from vaderSentiment.vaderSentiment i... |
86470e6dba5a245f94d7c0413e3992b908a239826191dcafcd0a4de6c5cf820f | Python | 6,046 | 151 | import os.path
import unittest
import tests.base_test
import tests.output_parser as output_parser
import tests.test_config
import tests.util
class Test(tests.base_test.BaseTest):
def setUp(self):
super().setUp()
self._test_base_dir = tests.test_config.TEST_BASE_DIR
self._test_dir = os.pa... |
a1e90ba628fd104ffcb5e8c2e0456661309d64f2c43abfe425bb4c5a95053a65 | Python | 6,046 | 284 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Fit FLIM data
"""
import os
import mbflim.utils as ut
import mbflim.parameters as par
import tools.flim.flim_set_processing as fl_setpro
import tools.flim.flim_visualization as fl_vis
#%% Parameters
# Parallelism
PROCESS_NB = 16
MAX_THREAD_NB = 32
#%% Fixed param... |
cc800fda0c116ba5c81406dd4fd10d1d069d7456dc1f87cbb0d824903722cd7a | Python | 6,046 | 178 | import argparse
import os
import os.path as osp
import time
import numpy as np
import torch
import torch.nn.functional as F
from sklearn.metrics import f1_score
import pandas
import json
import torch_geometric.transforms as T
from tqdm import tqdm
import spacy
import re
import ijson
from vaderSentiment.vaderSentiment i... |
461c30b3ee255c89bf8142203c99f2493fc8583f39bc4d74b0b7eb8ce4254c38 | Python | 6,047 | 110 | # -*- coding: utf-8 -*-
"""
Created on Sat Oct 15 17:50:32 2022
@author: tianj
"""
import os
import numpy as np
from torch.utils.data import Dataset, DataLoader
import torch
import torch.optim as optim
import dataset
import generator
import initialize_weights
import losses
import save_networks
#impor... |
bbf8d6dfb407be25446b3a0aabcba98cafdfae367c9b621c43267567e2c9aa0c | Python | 6,047 | 284 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Fit FLIM data
"""
import os
import mbflim.utils as ut
import mbflim.parameters as par
import tools.flim.flim_set_processing as fl_setpro
import tools.flim.flim_visualization as fl_vis
#%% Parameters
# Parallelism
PROCESS_NB = 16
MAX_THREAD_NB = 32
#%% Fixed param... |
c552e45b265678cb7f673b2550f72c71859417de9f2b4d11cef02ef15ccbf580 | Python | 6,047 | 175 | import torch
import torch.nn as nn
import torch.nn.functional as F
from config import Config
class CNNFeatureExtractor(nn.Module):
"""CNN特征提取器"""
def __init__(self, config):
super(CNNFeatureExtractor, self).__init__()
self.config = config
# 3个卷积层 + 2个池化层
sel... |
b6e8a5cae6c09f7c9ecb3f26bc5739cf15d394dce1f2890acc6f4013694f1b54 | Python | 6,049 | 175 | from typing import Any, Optional
import numpy as np
import torch
from torch import Tensor
import torch_geometric.typing
from torch_geometric.data import Data
from torch_geometric.data.datapipes import functional_transform
from torch_geometric.transforms import BaseTransform
from torch_geometric.utils import (
get... |
d5106a155cc554471244ae748095603446dd544b8dc0affff544eedd3805719c | Python | 6,049 | 147 | from collections import OrderedDict
from torch import nn
import numpy as np
from .modules import RetinaBlock, Bottleneck, VOneBlock, Identity
from .params import get_dog_params, get_div_norm_params, generate_gabor_param
from .backends import get_resnet_backend, get_vgg_backend
evnet_params = {
'base': ... |
1711eaacf6f577d5277e0933a5437881e2c3ba833d13358d3dc4244424b5edc2 | Python | 6,051 | 132 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
from ultralytics.engine.predictor import BasePredictor
from ultralytics.engine.results import Results
from ultralytics.utils import nms, ops
class DetectionPredictor(BasePredictor):
"""A class extending the BasePredictor class for prediction bas... |
d231958ee4588145f27004b8c83ea6381a8e85ab0e5a35b31adaa7e31fe60c8b | Python | 6,052 | 160 | import sys
import os
# Add parent directory to path
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import argparse
import torch
import pandas as pd
import numpy as np
from torch.utils.data import DataLoader
from rdkit import Chem, DataStructs
from rdkit.Chem import rdMolDescriptors
from... |
66897aa7792a7c33da2bdfb1d4be38b1326b8b6120d83117ceb5c3bafb3e1f08 | Python | 6,053 | 116 | from train_gtex import parse_gene_files,prepare_genes,ensure_no_donor_overlap, define_donor_paths, load_callbacks, load_trainer, ensure_no_gene_overlap
from pl_models import *
from datasets import *
import argparse
import yaml
import wandb
import lightning.pytorch as pl
from torch.utils.data import DataLoader
import wa... |
c78803a1575a817af4131845f49e4ad739f15e671d0f9cb4bfe17e85d13fd546 | Python | 6,054 | 179 | import os
import numpy as np
import pandas as pd
from pcntoolkit.normative import evaluate
from pcntoolkit.util.utils import compute_MSLL
from utils.training.nm_utils import calibration_descriptives, load_2d
def evaluate_nm(roi, y_true_te, yhat_te, s2_te, y_true_tr, nm, all_sites=None, sites_te=None, sites_tr=None, ... |
d2386782744ff5950235719c25225c12b4fd782ed61ffd23c1a1f28fcd801cd3 | Python | 6,056 | 205 | #!/usr/bin/env python
import os
import numpy as np
import argparse
import matplotlib
import matplotlib.pyplot as plt
matplotlib.use('agg') # Gets rid of GUI dependencies
np.set_printoptions(suppress=True)
USAGE="""
Shows entries with highest residual and optionally plots.
USAGE:
%s <residual_table> <options>
""... |
084836d2e3b29775c1033de37cc28c07852e5b3b30ea2d7a921cd83972017873 | Python | 6,057 | 211 | # Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If ex... |
1e4b382253e3e0d2b5412e2944b023b4ec686c927c5a292f56458c117d7ab6aa | Python | 6,057 | 173 | import pandas as pd
import py_neuromodulation as py_nm
import numpy as np
import os
import sys
import glob
from joblib import Parallel, delayed
sys.path.append('./')
sys.path.append('./')
sys.path.append('./neurokin/')
#sys.path.append('./neurokin/experiments/')
#sys.path.append('./neurokin/utils/')
#sys.path.append('.... |
20d3e2cae25ac678d20bbc9dea76460dfc7afcc1a2745ebe1681917d53be102b | Python | 6,057 | 178 | import argparse
from tqdm import tqdm
import torch
import torch.nn.functional as F
from torch.utils.data import Dataset, DataLoader
from ogb.nodeproppred import Evaluator
from logger import Logger
class SimpleDataset(Dataset):
def __init__(self, x, y):
self.x = x
self.y = y
assert self.... |
41468b3c1e4b8b8da81ae71ae1698ae28d1c0acec8cf6bbed126966d894e148b | Python | 6,059 | 134 | # Example of network that doesn't require clusters.
import torch
from torch import nn
from torch_scatter import scatter_mean, scatter_sum
from egnn_pytorch import EGNN_Sparse
# ruff: noqa: ANN001, ANN201
class VanillaConvolutionalLayer(nn.Module):
"""Vanilla convolutional layer for graph neural networks.
A... |
724c7e2f97f93ea1b988717f185cc9f221e6eded2df2336bb2e99b04c2420f40 | Python | 6,059 | 146 | # Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved
# (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
import copy
import json
import logging
import numpy as np
import pycocotools.mask as mask_util
from pycocotools.coco import COCO
from typing_extensions import override
cl... |
a44cc39830f1ea264a0dfb9b09d021d362e69bea8f64c3734b29973693e4d2b5 | Python | 6,059 | 126 | """
Methods to feed visual input to a system-under-test through the screen
"""
import copy
import logging
import os
import shutil
from typing import Union
import numpy as np
from PIL import Image
from pathlib import Path
from result_caching import store, is_iterable
from tqdm import tqdm
from brainscore_core.supporte... |
c56346d41762dafaeee5825a8d7233d15cf2fd704d51d9470cf178f14d675582 | Python | 6,059 | 95 | import os
import shutil
from nipype.interfaces.base import CommandLineInputSpec, File, TraitedSpec, CommandLine, BaseInterfaceInputSpec, BaseInterface
from traits.api import Str, Int, Directory, Bool, Either
from cvdproc.config.paths import get_package_path
# usage: mri_synthseg [-h] [--i I] [--o O] [--parc] [--robus... |
026b9a180621a769d5592c3515d5fb49f028f3f79499e1b29a685c0e7b4551c4 | Python | 6,060 | 163 | #!/usr/bin/env python3
# generate_all_reports.py
# ────────────────────────────────────────────────────────────
import os
from pathlib import Path
import numpy as np # 数值运算 :contentReference[oaicite:3]{index=3}
import pandas as pd # 表格导出 :contentReference[oaicite:4... |
22c842111278b48b3c3f12805ed1ab4d34edda6fa09fad8a78617ebfd91e08dd | Python | 6,060 | 192 | import argparse
from fastapi import FastAPI, WebSocket, WebSocketDisconnect
from pydantic import BaseModel
from docs.doc_modules.g_time_series.stock_data_manager import (
create_stock_manager,
)
from eir.setup.streaming_data_setup.protocol import PROTOCOL_VERSION
from eir.utils.logging import get_logger
logger =... |
be18a10d591466cbfe9dc271d50965218c548763d87cacd84483943dd5a42d27 | Python | 6,061 | 167 | import warnings
import pyfocus as pf
import numpy as np
import pandas as pd
import pkg_resources
import scipy.linalg as lin
from pandas_plink import read_plink
class IndBlocks(object):
"""
Class to wrap/iterate approximately independent regions
"""
CHRCOL = "chrom"
STARTCOL = "start"
STOPC... |
64ada53c1d80f13d9a13bff9e657f2114a3da0259cc4b8daa2ae1d1bac56e52b | Python | 6,062 | 178 | import sys
import os
import pandas as pd
import pyreadr
import torch
import glob
import functools
from torch_geometric.loader import DataLoader
import torch.nn.functional as F
from torch.nn import Linear
from torch_geometric.nn import GCNConv
from torch_geometric.nn import global_mean_pool
from torch_geometric.data imp... |
ae81d222579655d38c9afdf8236ac7adeabfe90fcc7dadbb69ad2b8577315c14 | Python | 6,062 | 147 | # Code reference: https://github.com/dansuh17/alexnet-pytorch
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from torchsummary import summary
import torch.optim as optim
from builder.models.feature_extractor.psd_feature import *
from builder.models.feature_extr... |
35f875eae31d108d5c43d7b64e91069805a61fe92f3cdc648ee3081b5a40bf62 | Python | 6,063 | 140 |
# This library contains functions for visualizing gaze data from the visual search in VR experiment.
#
# Authors: Bas van Opheusden, Angela Radulescu
import numpy as np
import keyboard
from matplotlib import cm
import matplotlib.pyplot as plt
def plot_gaze_episode(im, gaze, target_coords, connect_points=True, load_f... |
739e51ea0e95ded60ba0b061b9b463aec0e9f665ea79427e43c1a5315ca3fd50 | Python | 6,063 | 211 | """
Semi-random access to bz2 compressed data.
"""
import struct
from io import BytesIO
try:
import lzo
except Exception:
pass
from bx_extras import lrucache
class SeekableLzopFile:
"""
Filelike object supporting read-only semi-random access to bz2 compressed
files for which an offset table (bz... |
cb7de256ce09534c39caae635730112cc2398cdfeb3870e39d6edfdf37531070 | Python | 6,063 | 167 | # Copyright (c) DP Technology.
# 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.
"""
A modified version of the legacy DistributedDataParallel module that uses c10d
communication primitives. Th... |
d02aa20982a9cd234a822719f30f67377c8a76551090421956104a0def6fad48 | Python | 6,065 | 152 | """
EfficientNet-3D B0 from torchvision's 2D ImageNet pretrained weights
Uses I3D approach to inflate 2D weights to 3D, suitable for small-sample medical image classification
"""
import copy
import torch
import torch.nn as nn
import torchvision as tv
from torchvision.models import efficientnet_b0, EfficientNet_B0_Weigh... |
c8382c25d13386546f5190df2003b313143a23bae1a14ccef26409ee4a0070bb | Python | 6,066 | 160 | '''Tests for canonizers'''
from collections import OrderedDict
from functools import partial
import pytest
import torch
from torch.nn import Sequential
from helpers import assert_identity_hook
from zennit.canonizers import Canonizer, CompositeCanonizer
from zennit.canonizers import SequentialMergeBatchNorm, NamedMerg... |
bae26834b5a9247022cd3dabdde11e1a028fa93e5624a4bfb8d77bdca012cc99 | Python | 6,067 | 157 | import os
import glob
import re
class BIDSSession:
def __init__(self, bids_dir, subject_id, session_id):
"""
Initialize a BIDSSession instance.
:param bids_dir: str, BIDS root directory
:param subject_id: str, subject ID (e.g. "01")
:param session_id: str, session ID (e.g. "... |
bd0ccfa41a277e4c26128ffb02052901bc9bd8d14295dded96cf658d44d37b88 | Python | 6,069 | 175 | import torch
import numpy as np
import pandas as pd
from datetime import datetime as dt
from dataset import fast_merge,df_to_mask
from tqdm import tqdm
path='./boto-19/'
file='botometer-feedback-2019'
from utils import entropy,bigrams_freq
node=pd.read_json("../datasets/"+file+"/node.json")
label=pd.read_csv("../datas... |
e9b615ecf17fbbaa2355736193cda7412e6e4e74943743f0d08e9d482ec1bec8 | Python | 6,069 | 174 | import h5py
import logging
import numpy as np
import pandas as pd
from scipy.linalg import cho_solve, cho_factor
import heig.input.dataset as ds
def check_input(args):
# required arguments
if args.bases is None:
raise ValueError("--bases is required")
if args.ldrs is None:
raise ValueError... |
3afda707ed97badff2630bb65705ad019bb723955b81876383dcac5f35f6594b | Python | 6,071 | 154 | #############################################################################
# Copyright (C) 2020-2026 MEmilio
#
# Authors: Maximilian Betz
#
# Contact: Martin J. Kuehn <Martin.Kuehn@DLR.de>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Li... |
210d48424c48f244952ce0624c802d340c531274c1267879f0c0ac8c7858bbfe | Python | 6,073 | 199 | import logging
from collections.abc import Sequence
from copy import copy
from dataclasses import dataclass
from pathlib import Path
from shutil import rmtree
import pytest
from aislib.misc_utils import ensure_path_exists
from eir.setup import config
from eir.setup.config_setup_modules.config_setup_utils import recur... |
d6e3834737e1760ce22fb57d6955875d205e601de4f59cfea9ecc811fbcf0dd8 | Python | 6,073 | 152 | """ Model creation / weight loading / state_dict helpers
Hacked together by / Copyright 2020 Ross Wightman
"""
import logging
import os
from collections import OrderedDict
from typing import Any, Callable, Dict, Optional, Union
import torch
try:
import safetensors.torch
_has_safetensors = True
except ImportEr... |
977e3cbb84d150ec1520e0a5edcbb910781deba9ee5964df9039a868c83fb474 | Python | 6,074 | 170 | import re
from scipy.io import savemat
from tqdm import tqdm
from LocationRegressionHelper import *
from AutoEncoderHelper import *
import time
from numpy.random import default_rng
import argparse
import platform
import numpy as np
from pathlib import Path
import requests
print("Code is running on : " + ("cuda" if to... |
0b584402602f410520544223aebbeddfd990ed4b3b733fd5cf0ed60cca159935 | Python | 6,076 | 187 | from __future__ import annotations
import io
import sys
import pytest
from chemgraph.cli.commands import check_api_keys
from chemgraph.models.loader import load_chat_model
from chemgraph.models.openrouter import (
OPENROUTER_DEFAULT_MAX_TOKENS,
load_openrouter_model,
)
from chemgraph.models.supported_models ... |
1ab7959874b16d5a463c7320f00d82c5811d010c4ab13611875fcd2d8a4a30dd | Python | 6,076 | 169 | import logging
import h5py
import numpy as np
from scipy.spatial.distance import euclidean
from ccf_streamlines.coordinates import coordinates_to_voxels
from ccf_streamlines.projection import _matching_voxel_indices
def vector_to_3d_affine_matrix(vec):
M = np.array(
[
[vec[0], vec[1], vec[2]... |
6042291588b1629dd35a6dde6b561dc568fa0f989affc279de91b44a1f99d7fa | Python | 6,076 | 196 | import torch
import torch.nn as nn
from torch_geometric.utils import to_dense_batch
from layers import (
AttentiveLayer,
cross_attention_block
)
from activation import get_activation
class AttentiveMod(nn.Module):
def __init__(
self,
node_dim,
edge_dim,
... |
af21b910a8057b2a7ac8c6b8bf4fd070b13bce69adfcd38794d5a923d5f936fd | Python | 6,076 | 196 | import os
import matplotlib.pyplot as plt
import numpy as np
from dotenv import load_dotenv
from matplotlib import cm
from matplotlib.colors import to_hex
from mcmlnet.experiments.utils import polynomial_func
load_dotenv()
dash_styles = ["solid", "dot", "dash", "longdash", "dashdot", "longdashdot"]
def get_simula... |
b8ea6ea33b0d016d08fbd9cb1fca69ebc35646f3fe225e7479ad48a735b92a02 | Python | 6,077 | 121 | import numpy as np
import os
import tempfile
from ivim.models import sIVIM, diffusive, ballistic, intermediate, NO_REGIME, DIFFUSIVE_REGIME, BALLISTIC_REGIME, INTERMEDIATE_REGIME
from ivim.sim import noise, langevin
from ivim.seq.lte import MONOPOLAR, BIPOLAR
from ivim.io.base import read_im, write_im, write_bval, writ... |
31073b4934e90db946366b85b99e5016e4c581e993cc2fa1b41767847f10b30a | Python | 6,078 | 157 | """Train classification model.
Usage:
train_tex.py [options] <fold-id> <train-dir>
train_tex.py -h | --help
train_tex.py --version
Arguments:
<fold-id> A folder with train, validation, test split files.
Note, we do not check if train/valid/test overlap.
<train-dir> ... |
91c58b2733cd913f7179a021f916eac28ba28556a6401d2728d04781fa889a6e | Python | 6,080 | 114 | #!/usr/bin/env python
# coding: utf-8
'''
Dependencies:
pip install pandas numpy voxcell
chmod +x script.py
In this code we calculate total neuron numbers and save it in a txt file
**MAKE SURE THE PICKLE FILE USED HERE IS UP TO DATE!** (It won't load with Python 3.9 or older.. )
The pickle file is created in density3... |
15108ac7614abd2092d6130c4e98bcac642a42351f2c078d01c3f066317628aa | Python | 6,081 | 170 | # 移除 s1 层
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import init
from model.coatnet import conv_3x3_bn, MBConv
# Assuming conv_3x3_bn and MBConv are defined elsewhere in your code
class hswish(nn.Module):
def forward(self, x):
return x * F.relu6(x + 3, inplace=Tru... |
3112614e5bed4ec9bdaaadc8c360f0ed42f25e2677bea526b5e6db020e1c20ad | Python | 6,081 | 199 | from data_utils import filter_and_crop, get_image_T
from euler_gpu.preprocess import initialize
from euler_gpu.transform import transform_image_3d
from euler_register import EulerRegistrationProcessor
from typing import Dict
import glob
import h5py
import json
import numpy as np
import torch
class FPImageWarper(Euler... |
8ecd3f871edd192c8a7d7b653c2da73df158e2a8a85c904bf9be408023b2530d | Python | 6,081 | 171 | # -*- coding: utf-8 -*-
from collections import Counter
from flair.parser.utils.vocab import Vocab
import torch
class Field(object):
def __init__(self, name, pad=None, unk=None, bos=None, eos=None,
lower=False, use_vocab=True, tokenize=None, fn=None):
self.name = name
self.pad ... |
ae43ce92f2af87d5a87b7a36ccc0ba61e9ff5c3a821f18a51ebf8e626415eef7 | Python | 6,083 | 170 | # 移除 s1 层
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import init
from model.coatnet import conv_3x3_bn, MBConv
# Assuming conv_3x3_bn and MBConv are defined elsewhere in your code
class hswish(nn.Module):
def forward(self, x):
return x * F.relu6(x + 3, inplace=Tru... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.