sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
ec6b50294c5f36ebb2f5a8d3c302d42ee4e2b102f9085467ca4500abf27346e9 | Python | 6,435 | 167 | import pandas as pd
import os
from typing import List, Optional, Dict, Union, Literal
def merge_and_save_excel(
base_file_path: str,
additional_file_path: str,
match_column_base: List[str],
match_column_additional: List[str],
selected_columns: Union[List[str], str],
prefix: str = "",
outpu... |
23ad03d18fbec59ce4b0c2f4fbb4044ba10e8431db9b39177266eda4fa86c623 | Python | 6,436 | 200 | #!/usr/bin/env python
"""
The QGraphicsScene that is the backend of Steve and the base
class for the items that Steve will work with.
Hazen 10/18
"""
import os
import warnings
from PyQt5 import QtCore, QtGui, QtWidgets
item_id = 0
class SteveItem(object):
"""
Base class for items that Steve will work with ... |
1eb3833698449ddb3afd3abdeace21409ede1bfe95a22efd6dae81ade37e39bb | Python | 6,438 | 191 | import torch
import torch.nn.functional as F
def get_support_matrix(pcloud1, pcloud2, scale_factor=2.0):
"""
Compute global adaptive support matrix for two point clouds.
The distance threshold is based on the global average distance between points.
Parameters
----------
pcloud1 : torch.Tensor... |
5b093870d1e4a2aab285908d8609182351cfac945ad4e86c27851c6e43ef8e86 | Python | 6,438 | 177 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import csv
import io
import itertools
import time
from collections.abc import Iterable
from contextlib import closing
from datetime import timedelta
import datumaro.util
from rest_framework.serializers import ValidationError
from cvat.apps.dataset_... |
74841e9e644fec777a86d52d87b67eb6cb77ce73ea0e99499eac7c8dd0ae02f6 | Python | 6,439 | 124 | #!/usr/bin/env python3
"""Render the RG-NFT architecture schematic (Figure 1).
Drawn rather than photographed from code so the figure shows the two things the
prose cannot make visually obvious: that the reliability gate is driven by
signal-quality indices computed from the raw streams (never from the label), and
that... |
4d20b989e05c3c2e96df207a98c484002a8b997a330857a5d192c49f24907730 | Python | 6,440 | 196 | from __future__ import annotations
import json
import time
from typing import Final
import numpy as np
import osam
from loguru import logger
from numpy.typing import NDArray
from .._shape import Shape
from ._geometry import shape_to_xyxy_bbox
from ._osam_session import OsamSession
from ._shape_builders import MASK_R... |
227bbc6c0387cf3f6b078950313dc03d3e526d42e585bf396240b64627d4cf38 | Python | 6,441 | 158 | #############################################################################
# Copyright (C) 2020-2026 MEmilio
#
# Authors: Martin J. Kuehn
#
# Contact: Martin J. Kuehn <Martin.Kuehn@DLR.de>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Li... |
4d3790700dd11c0a5b465755360956a977f262f3a3b73a2597bd9e63848f1ba6 | Python | 6,443 | 126 | """ Test suite for pre processing routines."""
import numpy as np
from numpy.testing import assert_allclose
from pipeline.utils import galvo_corrections
##### Motion correction
def test_motion_correction_type():
# Double to double
test_scan = np.double(np.arange(16).reshape([4, 4]))
result = galvo_correct... |
8e6354e79420321e74c88babb9989866288b4fd2c6a05bd422bfeba014d8cbe8 | Python | 6,444 | 155 | import os
import glob
import json
from natsort import natsorted
import shutil
import tqdm
import shutil
from typing import Tuple
SAMPLE_LIST = ['5um S-20-28',
'5.2um LADAF-2021-17 Left Kidney',
'5.2um LADAF-2021-17 Right Kidney',
'2.58um LADAF-2020-27 Left Kidn... |
02b12573ecd1c7b50a27f6fec8d40b45311df4d7a0bad926e7d0a5d2256002cd | Python | 6,445 | 160 |
from numpy.random import seed
seed(42)
import tensorflow as tf
tf.random.set_seed(42)
import random
random.seed(42)
import tensorflow as tf
import csv
import numpy as np
import SimpleITK as sitk
import matplotlib.pyplot as plt
from numpy import argmax
import pandas as pd
import tensorflow.keras.backend as K
from tenso... |
aa684950fdf0ab95dd199380eb7f866093333814790b117fcefff4d20cd62e93 | Python | 6,445 | 221 | from typing import Callable, List, Union
import matplotlib.pyplot as plt # type: ignore
import numpy as np
from adjustText import adjust_text # type: ignore
from anndata import AnnData # type: ignore
from matplotlib.axes import Axes # type: ignore
from ..utils import state_loadings
from ..utils.data import _valid... |
24bfe851052db60cd46bffa0856bd5f9b7d6c7e0409ac4d302d4519731c9795c | Python | 6,447 | 194 | import globus_sdk
from globus_sdk.login_flows import LocalServerLoginFlowManager # Needed to access globus_sdk.gare
import os.path
import time
# Globus UserApp name
APP_NAME = "inference_app"
# Public inference auth client
AUTH_CLIENT_ID = "58fdd3bc-e1c3-4ce5-80ea-8d6b87cfb944"
# Inference gateway API scope
GATEWAY_... |
644b5845a846a43b1922387a03e801b8311d409a2a646b1d0cfacd7a61af127d | Python | 6,447 | 158 | import logging
from pkg_resources import resource_filename
import pandas as pd
import pyranges
from kipoi.data import SampleIterator
from kipoiseq.extractors import MultiSampleVCF, SingleVariantMatcher
from mmsplice.utils import pyrange_remove_chr_from_chrom_annotation,\
pyrange_add_chr_from_chrom_annotation
from m... |
e87e3b6695a5b49760d09b0d7ed5177e4cf301fa79ce0e90813ec08dcf6e3fe6 | Python | 6,447 | 180 | # Copyright (c) OpenMMLab. All rights reserved.
import copy
import platform
import random
from functools import partial
import numpy as np
import torch
from mmcv.parallel import collate
from mmcv.runner import get_dist_info
from mmcv.utils import Registry, build_from_cfg, digit_version
from torch.utils.data import Dat... |
64803d12f1ff5e396e34767b068d22576b9693a143c163a5fc2e1a676c1ba439 | Python | 6,448 | 175 | """
Static: Spectral Analysis
=========================
MEG data is useful because it has a high temporal resolution. We can take advantage of this by examining the spectral (i.e. frequency) content of the data. In this tutorial we will perform static spectral analysis on source space MEG data. This tutorial covers:
... |
751020451413cca7781551f6562ec1804a69e881cbe999b7bdae0529ff392fe0 | Python | 6,448 | 137 | """This script enables to launch predictions with SynthSeg from the terminal.
If you use this code, please the SynthSR paper in:
https://github.com/BBillot/SynthSR/blob/master/bibtex.bib
Copyright 2020 Benjamin Billot
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except i... |
80db29e37048ca62c31297371d22673c72fa88897467fe140d82f487315156b9 | Python | 6,448 | 187 | from .utils import *
from numpy.fft import fft
import math
from scipy.ndimage.filters import gaussian_filter
def mask_to_3d(mask,shape,include_mask = None):
'''
3dmask = mask_to_3d(mask,shape,include_mask = None)
Broadcasts a mask to a 3d array.
Usage:
s1mask = mask_contour_on_extent(nrefregions[... |
9b7fd5ecab0f033f553f4348af87e021675aef8c9d801641a2d9849b5c1e41d4 | Python | 6,450 | 179 | import sys
import yaml
import os
import numpy as np
import re
pathpath,myrun,ncluststr,cmethod = sys.argv[1:]
#myrun = 'runC00dMI3_brain'
#pathpath = 'PATHS/filepaths_IBL.yml'
#myrun = 'runIBLPasdM3_brain_pj'
#pathpath = 'PATHS/filepaths_IBL.yml'#
#myrun = 'runIBLPasdMP3_brain_pj'
'''
pathpath = 'PATHS/filepaths_ca... |
fa2e91e3438679e16bdbc9b075814a7e671069b332bd7261554278bc312b10a6 | Python | 6,450 | 176 | # Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved
"""Provides utility to combine a vision backbone with a language backbone."""
from copy import copy
from typing import List, Optional
import torch
import torch.nn as nn
from torch.nn.attention import sdpa_kernel, SDPBackend
from .act_ckpt_uti... |
6503e554d9487bfec805bc762d76ea31b84002003c36ca35fd60b1fe78a85843 | Python | 6,451 | 168 | import inspect
import torch
import warnings
from pathlib import Path
# Author: Jean Kossaifi
class BaseModel(torch.nn.Module):
"""Based class for all Models
This class has two main functionalities:
* It monitors the creation of subclass, that are automatically registered
for users to use by name u... |
6ee3d9611cfacf01c24287bb676e41299c23bc2f8a46d38af903dd971f87ca64 | Python | 6,451 | 147 | #This is the python program that reads in test pulse traces
#extracts baseline values, peak PSP, etc
#input is the full filename (including directory) of one of the traces, then python will find all the rest of the traces
#Outputs single file with each column containing a separate measure
#Can use Zbyszek's python prog... |
3544ad22d614a460a4ed44840cad724bfef38974d2ae78574d88257359decac1 | Python | 6,452 | 136 | import logging
import numpy as np
from brainscore_core.supported_data_standards.brainio.assemblies import merge_data_arrays, NeuroidAssembly, walk_coords
from brainscore_vision.model_helpers.brain_transformation import ModelCommitment
from brainscore_vision.model_helpers.brain_transformation.temporal import fix_timebin... |
6ea55430464f52fa87513b5efc77f994e2b9bdd3b61dedfc413543b2c0a05b1b | Python | 6,452 | 148 | import time
import nibabel as nib
import numpy as np
from lyroi.utils import get_tmp_dir, validate_extensions, format_time, clean_temp_dir, delete_dir
from lyroi.modes import get_model_folders, get_folds, get_suffixes
from lyroi.nnunet_interface import nnunet_predict, get_torch_device
from pathlib import Path
from shu... |
dedbb0fe39ba072b500035a472946722b7bdff2ef947adcf19a5dbd8ac8a0531 | Python | 6,452 | 171 | # -*- coding: utf-8 -*-
import logging
from dipy.core.gradients import get_bval_indices
import numpy as np
from scilpy.gradients.bvec_bval_tools import B0ExtractionStrategy
from scilpy.image.utils import volume_iterator
def extract_dwi_shell(dwi, bvals, bvecs, bvals_to_extract, tol=20,
block_s... |
d8e21e84e44de9a3a6a1636fa45e82c595ac78d564e39f53e607c0944c57c6d0 | Python | 6,453 | 193 | """Network constructor for fully connected surrogate models in PyTorch Lightning."""
from typing import ClassVar
import lightning as pl
import torch
import torch.nn as nn
from mcmlnet.utils.logging import setup_logging
logger = setup_logging(level="info", logger_name=__name__)
def fc_building_blocks(
arch_typ... |
e36272e059da2d2e060da2adbc126fdab617f69ddab4cb38f768ba3b548a538e | Python | 6,454 | 171 | import os
import pandas as pd
import csv
import gzip
import os.path
import pickle
import datetime
from tqdm import tqdm
from metaphlan.utils.merge_metaphlan_tables import merge
from .utilities import run_cmd, ReadsData, check_conda_qiime2
import json
import shutil
import tarfile
import os
import yaml
def check_metad... |
0e3ec73cfb6194135bc65f214a54d17ac03a052c0b9271a4efe5f5c4c0f432fd | Python | 6,455 | 166 | # define multi-offset transformer reconstruction network
import torch
import numpy as np
import torch.nn as nn
from utils.utils import *
from einops import rearrange
import torch.nn.functional as F
class Attention(nn.Module):
def __init__(self, dim, dim_head=64, heads=8):
super().__init__()
... |
6bb5a74d8ae1619d28d77866e57c6c474c6577ed02a8bd7125549c81b01bd551 | Python | 6,455 | 172 | import os
import pandas as pd
import csv
import gzip
import os.path
import pickle
import datetime
from tqdm import tqdm
from metaphlan.utils.merge_metaphlan_tables import merge
from .utilities import run_cmd, ReadsData, check_conda_qiime2
import json
import shutil
import tarfile
import os
import yaml
def check_metad... |
f6b42da5b36d88270b1076e31779ffb6afc498e775406d45987dca315a1ed9aa | Python | 6,458 | 194 | import torch
import os
import argparse
import torchvision.models as models
import torchvision.transforms as transforms
from torch.utils.data import DataLoader
from torchvision.datasets import ImageFolder
from tqdm import tqdm
from pathlib import Path
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
project_root = Path(__file_... |
6d3aa8b22b649023d4f42b0e3a4f16569aab1c40edc05cecc04ba57f70c5750a | Python | 6,460 | 271 | 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
dataset_names = [
'botometer-feedback-2019', 'botwiki-2019', 'celebrity-2019', 'cresci-2015', 'cresci-2017', 'cresci-rtbust-2019', 'cresci-stock-2018', 'gilani-2017... |
fbc872dc6f4af314bd630743587237d40768c110199b426deecf6c3bdd3c3384 | Python | 6,462 | 157 | import sys
import time
import getopt
import numpy as np
import scipy.ndimage as nd
import scipy.signal as sg
from skimage import io as skio
from skimage import img_as_ubyte
def get_mask_dapi(dapi_file,min_brightness,width_pixel,height_pixel,chip,prefix,need_filter,mask_mode):
print('loading ssDNA ...',file=sys.stde... |
bebde4a7175dc9a6a32ba1c5def53f42eb54ddc6b6f8810401e644f34595a476 | Python | 6,463 | 212 | #!/usr/bin/env python
"""
The core functionality for a HAL hardware module. Most HAL
modules that interact with hardware are sub-classes of
this module.
Hazen 04/17
"""
#import copy
import faulthandler
import time
from PyQt5 import QtCore
import storm_control.sc_library.halExceptions as halExceptions
import storm_c... |
f3870a1a0dd135feab9f1ab037e50a76375aec80cbe1ef5048d1e60ac72801e1 | Python | 6,463 | 172 | """
Find thresholds (used to binarize the heatmaps) that maximize mIoU on the
validation set. Pass in a list of potential thresholds [0.2, 0.3, ... , 0.8].
Save the best threshold for each pathology in a csv file.
"""
# based on https://github.com/rajpurkarlab/cheXlocalize/blob/v1.0.0/tune_heatmap_threshold.py
from arg... |
6aec868c7a00a3b17ca7abd87f2fbfbbbde645c7c34e885969b10c4635026c2a | Python | 6,466 | 173 | # Copyright (C) 2019-2022 Intel Corporation
# Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import os.path as osp
import shutil
from collections.abc import Callable
from glob import glob
from datumaro.components.annotation import AnnotationType
from datumaro.components.dataset import StreamDataset... |
b99fc765d90b5c16388a602c6e1975c4d7d37db034e4b8d8fbe5ed1e7ca07d69 | Python | 6,466 | 199 | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import os
import torch
import biotite.structure
import numpy as np
import pandas as pd
from biotite.structure.io import pdbx, pdb
from biotite... |
e5711e146a2a548c5eb019988e3006d23afda171c8e091e67dda67b6181e4379 | Python | 6,466 | 197 | """
Test the sensitivity of nest results on input parameters
"""
import numpy as np
import scanpy as sc
import pandas as pd
import os
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.metrics import jaccard_score, normalized_mutual_info_score
from scipy.optimize import linear_sum_assignment
import ra... |
f92a1ba01892bcbfaee56f6ba593e364a15ee4a6953d2032b19ed05b49b83e97 | Python | 6,468 | 217 | import math
from typing import Literal
import torch
import torch.nn.functional as F
from torch import nn
from eir.models.fusion.seq_out_fusion_attention import CrossAttention
from eir.models.layers.attention_layers import SwiGLU
from eir.models.layers.cnn_layers import adjust_num_heads
from eir.models.layers.norm_lay... |
4fa9c334b8710e693b6cbd37b547b0e78ec335fedd0e80543d3808070c183c74 | Python | 6,469 | 163 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Compute a Track Orientation Density Image (TODI).
Each segment of the streamlines is weighted by its length (to support
compressed streamlines).
This script can afterwards output a Track Density Image (TDI) or a TODI with SF
or SH representation, based on streamlines... |
19ad7cc256538deff6448fedc11addd56380e7ed3524148ade126de927baf415 | Python | 6,470 | 118 | # -*- coding: utf-8 -*-
"""
Created on Thu Nov 18 18:44:08 2021
@author: Yoshi
"""
import warnings
warnings.simplefilter(action="ignore",category=FutureWarning)
import os
program_path = os.getcwd()
os.chdir(f"{program_path}/motion_corrector")
from motion_corrector import *
os.chdir(f"{program_path}/data_extracto... |
072772d902998e7f96eb4f46938eec6076c8dc09c2bf4e529fed25a847d88510 | Python | 6,471 | 190 | # -*- coding: utf-8 -*-
"""
Created on Mon Sep 18 16:39:35 2023
@author: szh
"""
import numpy as np
import pandas as pd
from tqdm import tqdm
import scipy.sparse as sp
from SpaNCMG import Mix_SpaNCMG
from Mix_adj import Transfer_pytorch_Data
import torch
import torch.backends.cudnn as cudnn
cudnn.deterministic = Tru... |
0f0ae0d7fcf497f97016b6258f90f5ef8f5db92fcad7d397491b45c78d2c20b4 | Python | 6,471 | 196 | import os
import UMPA as u
import numpy as np
from matplotlib import pyplot as plt
from PIL import Image
import scipy.constants as sc
from glob import glob
import time
def frankotchellappa(dpc_x, dpc_y):
'''
Frankt-Chellappa Algrotihm
input:
dpc_x: the differential phase a... |
27bd4a1aba54f1a64e591fc220ab29eb216e8a574ca8f7c2c36df5862623c885 | Python | 6,472 | 199 | # TORCH IMPORTS
import torch
import torch.nn as nn
import torch.optim as optim
import torch.backends.cudnn as cudnn
from torch.optim.lr_scheduler import CosineAnnealingLR
# AIHWKIT IMPORTS
from aihwkit.simulator.configs import InferenceRPUConfig
from aihwkit.simulator.configs.utils import WeightClipType
from aihwkit.s... |
2b13b8db1ee95ca84810860abcab279fe96c9436e4ccda395a9a2214a2fcc959 | Python | 6,472 | 191 | from __future__ import annotations
import dataclasses
import json
from collections.abc import Mapping
from pathlib import Path
from typing import Any
from chemgraph.models.endpoints.configuration import (
endpoint_api_key,
resolve_argo_user,
resolve_base_url_for_spec,
select_endpoint_for_config,
)
fro... |
142195bd74971bbfb8de871e731d412b7a505c2a7389ca8f5d0f29af2a3701e7 | Python | 6,474 | 203 | """
2D visualization primitives based on Matplotlib.
1) Plot images with `plot_images`.
2) Call `plot_keypoints` or `plot_matches` any number of times.
3) Optionally: save a .png or .pdf plot (nice in papers!) with `save_plot`.
"""
import matplotlib
import matplotlib.patheffects as path_effects
import matplotlib.pyplo... |
2f661c8462331c3cf1deb3d6796ddf43322552dd029c760868ba73bf46fbcc3d | Python | 6,475 | 203 | """Tools for looking up python objects from strings."""
import fnmatch
import importlib
from functools import partial
class FindCallable:
def __init__(self, _dict, header='Function', ignore_case=True):
"""Matches a name to a callable object within one module or package.
Case-insensitive.... |
3c2e4af93d8a44a10bbcc8aaaf3984ed9679b9f22cab6683624263708795b69a | Python | 6,476 | 199 | #!/usr/bin/python3
#
import os
import sys
import argparse
import shutil
import numpy as np
from sklearn.neighbors import NearestNeighbors
from uac import utils
import uac.vars as var
# Create the parser
my_parser = argparse.ArgumentParser(description="UAC fibre mapping")
# Add the arguments
my_parser.add_argument("t... |
9515a7ca92b61abb4e732fc115d49ec50d8db6e78656317b8eb5d3613ec8b50f | Python | 6,479 | 166 | import torch
import torch.nn as nn
from timm.models.layers import DropPath, trunc_normal_
from timm.models.registry import register_model
from torchsummary import summary
# 论文题目:Rewrite the Stars
# 中文题目: 重写星操作
# 论文链接:https://arxiv.org/pdf/2403.19967
# 官方github:https://github.com/ma-xu/Rewrite-the-Stars
# 所属机构:东北大学,微软... |
1f7343ea76a6501f008f0bdbfee975d9a44579e9ac970c1ad5feda32665d0258 | Python | 6,481 | 155 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
import contextlib
import subprocess
import time
from pathlib import Path
import pytest
from tests import SOURCE
from ultralytics import YOLO, download
from ultralytics.utils import ASSETS_URL, DATASETS_DIR, SETTINGS
from ultralytics.utils.checks imp... |
1451978dacc0f74db1119ad967d7882f4817c65f50357bc4f29be144a93ea3bc | Python | 6,482 | 195 | # Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved
import io
import math
import matplotlib.pyplot as plt
import numpy as np
import pycocotools.mask as mask_utils
from PIL import Image
from .som_utils import ColorPalette, draw_box, draw_mask, draw_text
def render_zoom_in(
object_data,
... |
06507677d2045ada63299f91955a194be67048de83452552435a2557506d4d36 | Python | 6,484 | 173 | import numpy as np
from scipy.signal import resample
from scipy.signal import butter, filtfilt,lfilter
import numpy as np
def butter_bandpass(lowcut, highcut, fs, order=5):
nyq = 0.5 * fs
low = lowcut / nyq
high = highcut / nyq
b, a = butter(order, [low, high], btype='band')
return b, a
def butte... |
264eae8b5c565787a39c54c8f296291205fb34805d47abcd5c8388b34e409475 | Python | 6,486 | 185 | import collections
from typing import Literal
import numpy as np
from matplotlib import pyplot as plt
from scipy.stats import sem, kstest
from argclz import AbstractParser, as_argument, argument, str_tuple_type
from argclz.dispatch import Dispatch, dispatch
from neuralib.atlas.util import iter_source_coordinates, Sou... |
5a10605639f5dca47f6ede8db614c338e6948db9d916b919a72f2f43876a916a | Python | 6,486 | 166 | from typing import Optional, Union
try:
from collections import Iterable
except ImportError:
from collections.abc import Iterable
from numbers import Real
import warnings
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import CrossEntropyLoss
# based on:
# https://github.com/z... |
754135c0d40d04061087f2b902c577c4b8d74eee2bb02c79a0b34d023e2d44e2 | Python | 6,487 | 167 | import numpy as np
import polars as pl
from polars.exceptions import SchemaError
from argclz import AbstractParser
from neuralib.suite2p import Suite2PResult
from neuralib.util.verbose import fprint, print_save
from rscvp.util.cli.cli_io import CELLULAR_IO
from rscvp.util.cli.cli_output import DataOutput
from rscvp.ut... |
e5ccf0c8e70ac4cec6ec3f8ce18bfe53e61454a110940f0f711e17349f46abc6 | Python | 6,487 | 138 | import numpy as np
import tensorflow as tf
from src import TGCNN_layer
class TGCNN_Model(tf.keras.Model):
def __init__(self, num_filters=2, num_nodes=97, num_time_steps=100,
filter_size=3, variable_gamma=True, exponential_scaling=True, dropout_rate = 0.2,
lstm_units=16, fcl1... |
0fe71761a4c4d01674094e02312a7197462ee153f05d7a2a2e698a649f1013c6 | Python | 6,489 | 154 | # This file is part of connectome-manipulator.
#
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2024 Blue Brain Project/EPFL
import connectome_manipulator.connectome_manipulation.manipulation.syn_removal as test_module
import numpy as np
import os
import pytest
from bluepysnap import Circuit
from numpy.testing... |
290a885cd46c585738aff62e5ec3229860ff49d3a12099d505914e50aa22d4ff | Python | 6,489 | 183 | """KAN PyTorch Lightning model, inherited from the BaseModel class."""
import torch
import torch.nn as nn
from hydra.utils import instantiate
from omegaconf import DictConfig
from mcmlnet.training.models.base_model import BaseModel
from mcmlnet.training.plotting import (
display_parameter_marginals,
display_s... |
c2d362601a7300516c31358bd67c19dff8e5dddcb3a00e9a024b6dacf2e6af37 | Python | 6,490 | 185 | import torch
from typing import Optional
from mlcg.nn.losses import _Loss
from mlcg.data import AtomicData
class LinearReg(torch.nn.Module):
"""
A linear regularization module that computes a scaling factor based on
the number of atoms in a system, using learnable parameters.
Attributes:
para... |
7034745648e3922988e112f8e4db15e69e71debfdbe7de43cc2c41c31727cab4 | Python | 6,492 | 162 | import atexit
import logging
import os
from typing import Any, Optional, Union
import torch.distributed
import torch.multiprocessing as mp
from torch_geometric.distributed import DistNeighborSampler
from torch_geometric.distributed.dist_context import DistContext
from torch_geometric.distributed.rpc import (
glob... |
69a4cdf0b78e7a05518e84a234da9f45a70c52a3b58aac166890452144786396 | Python | 6,493 | 189 | # -*- coding: utf-8 -*-
# python standard library inputs
import os
# external inputs
import numpy as np
import nibabel as nb
import matplotlib.pyplot as plt
from numpy.linalg import norm
from scipy.interpolate import griddata
from descartes import PolygonPatch
from shapely.geometry import mapping
from skimage.draw im... |
aaa879f7d699449a799db831469fbd5c76a77538b790001316898f2edfdb9a2d | Python | 6,494 | 148 | '''
N4
'''
import numpy as np
import sys
def intro():
print("""
SHORT List of potential energy surfaces for N4:
P: potential energy, G: Gradient, D: Nonadiabatic coupling vector
This is listed at the end of description to show the availability.
For example: P/G means both potential energy and gra... |
7292d84ced9f97368c1a2e9d6d489107b45ecb9444cc0149cbcf119f7e08a1e4 | Python | 6,496 | 196 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import json
import os
import zipfile
import pytest
from cvat_sdk.api_client import exceptions
from cvat_sdk.core.proxies.projects import Project
from cvat_sdk.core.proxies.tasks import ResourceType
from .util import TestCliBase, generate_images
c... |
c5301d4b37cc9d94f994f5186a7ab3c6e79d3327f0e3f07da1b8c1c6c122bbc0 | Python | 6,496 | 132 | import argparse
import json
import pkg_resources
from .dataset_downloading import download
from .dataset_downloading import continue_from
from .dataset_downloading import continue_from_fastq
from .export_data import export
from .prerun_configs import set_environment
from .dataset_downloading import download_qiita
from ... |
eb95fb22157180952b8d87e91272795d72181005acef98b9d192df131c95d9a5 | Python | 6,497 | 216 | import os
from types import SimpleNamespace
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
import numpy as np
import pytest
pytest.importorskip("PySide6")
from PySide6.QtWidgets import QApplication, QWidget
_APP = QApplication.instance() or QApplication([])
from musclex.modules.ProjectionProcessor import (... |
d2887b40c2897c4d75e499d2cbcfefe2e73f358cf8ba6571db54765891a66534 | Python | 6,498 | 168 | import typing
import asyncio
from . import thalamus_pb2
from . import thalamus_pb2_grpc
from . import grpc_tls
from .task_controller.util import create_task_with_exc_handling
import grpc.aio
class CancelableQueue:
def __init__(self, cancel_callback: typing.Callable[[], None]):
self.queue = asyncio.Queue()
s... |
10ff4f94f73da2bc01afc49ee8360350c0bed72f12783d0d9da2e6559d8dc1c7 | Python | 6,500 | 327 | # -*- coding: utf-8 -*-
"""
Created on Sat Jun 20 14:00:49 2015
@author: ckirst
"""
# open data
#mount windows folder
#sudo mount -t vboxsf D_DRIVE ./Windows/
#fn = '/home/ckirst/Science/Projects/BrainActivityMap/Data/iDISCO_2015_06/Adult cfos C row 20HF 150524.ims';
#fn = '/run/media/ckirst/Christ... |
f9b6897daf7c4a3e1da76588634a52d16e5ba7bc39713f184c040aa46dfd9d94 | Python | 6,500 | 187 | import argparse
import torch
from tqdm import tqdm
import torch.nn.functional as F
from torch_geometric.data import ClusterData, ClusterLoader, NeighborSampler
from torch_geometric.nn import SAGEConv
from ogb.nodeproppred import PygNodePropPredDataset, Evaluator
from logger import Logger
class SAGE(torch.nn.Modul... |
fd6af99a19afbdb20c841f2022a1f935ad8ecbf6f9a73fa31a186c3c7676b9b7 | Python | 6,500 | 156 | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
from torch.nn import functional as F
from typing import Tuple
from ..modeling import ... |
cadb24fccdb3adbe045c657b48f30843d73eb4d1083be0e30bd069941f183eec | Python | 6,501 | 144 | import numpy as np
from tqdm import tqdm
import tensorflow as tf
import math
def compute_entropy(posteriors):
return -np.sum(posteriors[...,1:] * np.log(posteriors[...,1:] + 1e-8), axis=-1)
def compute_unary(posteriors, weight=10):
return -weight * np.log(posteriors + 1e-10)
def compute_pairwise(region_cent... |
b38030048c49993c6f8d10d76efa9c0ee0c04de8870faebddfc151f472b17104 | Python | 6,503 | 163 | import warnings
warnings.filterwarnings("ignore", message="It is not recommended to directly access")
import torch
import torch.nn as nn
import torch.nn.functional as F
class CommonFeatureExtractor(nn.Module):
def __init__(self, fp_dim, hidden_size, similarity_threshold=0.6):
super(CommonFeatureExtractor, ... |
59490d943f0c2b772a5c9eb8a5de8ffef19c260a6d3ab54309d1a630f1c7d4e0 | Python | 6,505 | 130 | import os
from importlib import import_module
from pathlib import Path
cell_graph_config = {
"cell_f_list": [
'fourier',
10,
False,
[
'area',
'r_equiv',
'r_maj',
'r_min',
'angel',
'ecc',
'maj_x',
... |
be16904427a0fa10784ace40e0b1934b8ed3a86985c3c7eff7e68854823b92aa | Python | 6,506 | 271 |
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
dataset_names = [
'botometer-feedback-2019', 'botwiki-2019', 'celebrity-2019', 'cresci-2015', 'cresci-2017', 'cresci-rtbust-2019', 'cresci-stock-2018', 'gilani-20... |
5773448dd96919a6755cb06855052e0d244f6a48a2a681def7a1300e27917147 | Python | 6,508 | 154 | import os
import json
import numpy as np
import nibabel as nib
# Add the directory containing Reconstructor class to the Python path
import sys
project_dir = '/export01/data/vgrouza/mbpko'
sys.path.append(project_dir)
from src import pv_custom_recon
from src import bipolar_corrections
from src import mwf_rpca
# crea... |
7a3a89dc1d15ce29cd8b126f69103ef174d6bf9be3087ca3969e108e454d2724 | Python | 6,508 | 177 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Computes a very simple connectivity matrix, using the streamline count and the
position of the streamlines' endpoints.
This script is intented for exploration of your data. For a more thorough
computation (using the longest streamline segment), and for more options abo... |
7b143ee9b45e3e21f8e28edffd5a019e4ca3efd3df1a31ff872028a254c88a1f | Python | 6,509 | 179 | import copy
from abc import ABC, abstractmethod
from typing import Any, Tuple
import torch
from torch import Tensor
from torch_geometric.data import Data
from torch_geometric.transforms import BaseTransform
from torch_geometric.utils import to_torch_csc_tensor
class RootedSubgraphData(Data):
r"""A data object d... |
a401937e429c9cf9e192933ce42946e74908e6b90b6b991d76f283a403ed495b | Python | 6,509 | 127 | import os
from importlib import import_module
from pathlib import Path
cell_graph_config = {
"cell_f_list": [
'fourier',
10,
False,
[
'area',
'r_equiv',
'r_maj',
'r_min',
'angel',
'ecc',
'maj_x',
... |
c18ba830fe7e27cc8bdbefcfe04e95027674fc71741fc996ba7c39866dd764e4 | Python | 6,509 | 187 | import argparse
import torch
from tqdm import tqdm
import torch.nn.functional as F
from torch_geometric.data import ClusterData, ClusterLoader, NeighborSampler
from torch_geometric.nn import SAGEConv
from ogb.nodeproppred import PygNodePropPredDataset, Evaluator
from logger import Logger
class SAGE(torch.nn.Modul... |
c700593e8aa9aac9e4402ea91173224a55c5eb4466d8beef153c8f74bfc5828c | Python | 6,509 | 195 | from typing import Literal
import matplotlib.pyplot as plt
import numpy as np
from iblatlas.atlas import AllenAtlas
from iblatlas.regions import BrainRegions
from matplotlib.axes import Axes
from neuralib.io import ATLAS_CACHE_DIRECTORY
from neuralib.typing import ArrayLike, PathLike, ArrayLikeStr
__all__ = ['IBLAtl... |
029809e3292a45ce21905f2f6b53b7d2e63778faf6a2ca47f138b26e33ee4112 | Python | 6,510 | 151 | import numpy as np
import random
import math
import matplotlib.gridspec as gridspec
import matplotlib.pyplot as plt
import copy
pi = math.pi
D_enc = 2.02 # displacement encoding frequency (cycles/mm), we use 2.02 cycles/mm which gives 0.495 mm of displacement before phase wrap occurs
def convert_mm_to_phase(meas_mm)... |
785df90f65eadb8ae1147698ed5d2f271928e18bb76ad242cbf1ef464be5f6f3 | Python | 6,512 | 153 | import json
import enum
import typing
import logging
import sqlite3
import jsonpath_ng
import jsonpath_ng.ext
from .config import ObservableCollection
LOGGER = logging.getLogger(__name__)
class MatchContext(typing.NamedTuple):
value: ObservableCollection
class PatchMatch(typing.NamedTuple):
value: typing.Optio... |
df9a1db45d98bca5e5ac345eaaf7189dec29d42575f247c4b4420d6ae713aa07 | Python | 6,514 | 278 |
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
dataset_names = [
'botometer-feedback-2019', 'botwiki-2019', 'celebrity-2019', 'cresci-2015', 'cresci-2017', 'cresci-rtbust-2019', 'cresci-stock-2018', 'gilani-201... |
93ebcde6ddd410601d3f8d4ef4b6a8de2062d29fc4a4236fef9cf8e929500f22 | Python | 6,516 | 186 | """Shared MCP tools for Globus Transfer file staging.
Call :func:`register_transfer_tools` to add ``transfer_files``,
``check_transfer_status``, and ``list_remote_files`` to any
:class:`~mcp.server.fastmcp.FastMCP` (or
:class:`~chemgraph.mcp.cg_fastmcp.CGFastMCP`) server instance.
These tools allow an LLM agent to st... |
d41b9fdeef869af122f086f497452eccff0575c3ad18581fd7e2b9e9f07f6925 | Python | 6,516 | 150 | #!/usr/bin/env python3
"""Stage 0 for DD-Database -- interrogate the recordings before building anything.
Same discipline as the UL-DD stage 0: establish what the labels actually support
before committing to a target definition. DD-Database annotations are bare
'Event' marks with no severity and no graded scale, so th... |
32b2f4c5932edfcda0a05d431e71ec2528f3d5f69870713484746c2e7fdb4ee1 | Python | 6,518 | 149 | """
Preparing fMRI Data
===================
In this tutorial we discuss how to prepare fMRI data. This tutorial covers:
1. Preparing group-ICA data
2. Preparing anatomically parcellated data
3. Saving and loading prepared data
fMRI data needs to be preprocessed in a particular way to train a dynamic network model (H... |
276fd958c9c18ec56dc283794a9ca48541c29a17f5a8b9c1b2a9e0cdea69ad74 | Python | 6,519 | 179 | import copy
import warnings
from typing import Dict, List, Optional, Union
import torch
import torch.nn.functional as F
from torch import Tensor
import torch_geometric
from torch_geometric import is_compiling
from torch_geometric.typing import EdgeType, NodeType, OptTensor
from torch_geometric.utils import cumsum, sc... |
edbfb11dd495faa31e5dd3a7bdb1b919bcb25ad01846fadfa50884cbd5c38f4b | Python | 6,520 | 155 | import os
import glob
import json
from natsort import natsorted
import shutil
import tqdm
import shutil
from typing import Tuple
SAMPLE_LIST = ['5um S-20-28',
'5.2um LADAF-2021-17 Left Kidney',
'5.2um LADAF-2021-17 Right Kidney',
'2.58um LADAF-2020-27 Left Kidn... |
3dbdfd48d0d6b16a7665f546b53b98135ecca7fdda8eb7961e751c59495a529d | Python | 6,521 | 156 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
"""Create a task with honeypots: a pool of ground truth frames, a few of which
are mixed into every annotation job, so each annotator's work can be scored
against known answers without a separate review pass.
Steps:
1. Collect the files from --ima... |
eefb6157d7730aba9da757d9dde003eef57f0f1209536ff18b40b955b08e0457 | Python | 6,521 | 156 | import torch
import torch.nn as nn
import torch.nn.functional as F
# 论文题目:Multi-scale Attention Network for Single Image Super-Resolution
# 中文题目: 单图像超分辨率的多尺度注意力网络
# 论文链接:https://arxiv.org/abs/2209.14145
# 官方github:https://github.com/icandle/MAN
# 代码整理与注释:公众号:AI缝合术
# AI缝合术github:https://github.com/AIFengheshu/Plug-pla... |
375962b91bb5334a237f8e40a72a153305d7e25fc35c38d2ca354c38170322de | Python | 6,523 | 177 | # -*- coding: utf-8 -*-
"""
Created on Wed Dec 20 21:04:42 2023
@author: Administrator
"""
import torch
import torch.nn as nn
import torch.nn.functional as F
import math
import torch.distributions as dist
import pdb
import math
import numpy as np
import torch
from torch import nn
from .utils import bui... |
3ae862f9ca31c403441597c5b68ec32de9f9a9d1df9ed7c6c117ab20376be83f | Python | 6,523 | 130 | import os
from importlib import import_module
from pathlib import Path
cell_graph_config = {
"cell_f_list": [
'fourier',
10,
False,
[
'area',
'r_equiv',
'r_maj',
'r_min',
'angel',
'ecc',
'maj_x',
... |
5c82a30dc100bc9c1bb97c0c14708ed192bd90de764651dc8393fa8fad7aec0c | Python | 6,523 | 173 | import click as ck
import pandas as pd
import torch as th
import numpy as np
from torch import nn
from torch.nn import functional as F
from torch import optim
from sklearn.metrics import roc_curve, auc, matthews_corrcoef
import copy
from torch.utils.data import DataLoader, IterableDataset, TensorDataset
from itertools ... |
aaa7152557e2b30c0c4a455c7da24e79837a3e77b258955330399d977bdc30b1 | Python | 6,523 | 179 | from brainscore_vision.model_helpers.check_submission import check_models
import functools
import numpy as np
import torch
from transformers import AutoFeatureExtractor, CvtForImageClassification, CLIPVisionModel, CLIPProcessor, CLIPModel
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
fr... |
bbdc8f80b3aa7bc36047de0d7aa24adb19e461bbcd7a39293f83fb24c54f54c3 | Python | 6,524 | 186 | # 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 pytest
from nab.sweeper import (
Anomaly... |
18709efe03e6490d2521b21ffc2ff22f970f3c8e15b6096cb0c78714ee1e23c8 | Python | 6,525 | 156 | import numpy as np
import pandas as pd
from causallib.estimation.base_estimator import IndividualOutcomeEstimator
class OverlapViolationEstimator(IndividualOutcomeEstimator):
"""
A causallib-compatible model returning NaNs with appropriate format and indexing.
Meant to be used when overlap violations are... |
a24c2203efae89be7135deeef7b36e4c5785236c88b43622a5b417530f7fd5fe | Python | 6,527 | 171 | import os
import pandas as pd
import numpy as np
import librosa
from torch.utils.data import Dataset
from torchvision import transforms
import sys
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from datasets.dataset_scale import DatasetScale
class AccelVelDirDataset(... |
b5139b8f6a87dbcfa47b1c4fb5ec0bd1042bbcf9a4464f1f4d724e938af475ee | Python | 6,527 | 182 | #!/usr/bin/env python
"""
Python interface to the C image manipulation library. The library
is used to speed up the rendering of the image in the UI. My experience
was that for large images, such as those from a sCMOS camera, using numpy
to do the image scaling and type conversion was not fast enough.
Hazen 09/15
"""... |
0007e359e4b6330e864c5c8f06d87ab4f3745a2b5d8c5b7105b33c0dfd96f828 | Python | 6,528 | 204 | # Kai Sandbrink
# 2023-09-28
# This script contains utility functions for the neural network scrips
# %% LIBRARY IMPORT
import numpy as np
import pandas as pd
import os, ast, glob
import matplotlib.pyplot as plt
import matplotlib as mpl
import seaborn as sns
import torch
from ObserveBetEfficacyTask import ObserveBet... |
e3333ec099c9f0185aa04d949ddbacac74a1411bf8c890c76c9d17b151380df4 | Python | 6,528 | 188 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
from __future__ import annotations
import textwrap
import pytest
try:
import numpy as np
from cvat_sdk.masks import decode_mask, encode_mask
except ModuleNotFoundError as e:
if e.name.split(".")[0] != "numpy":
raise
numpy_... |
7b658765dc2752518630643e574e8c67d1cbdc405d28d8a955e281a136ac069b | Python | 6,529 | 210 | from typing import Final, Literal
import brainrender
import numpy as np
import polars as pl
from brainrender import Scene
from brainrender.actors import Volume, Points
from argclz import argument
from neuralib.atlas.brainrender.core import CAMERA_ANGLE_TYPE
from neuralib.atlas.util import allen_to_brainrender_coord
f... |
ccc558d6a96a3f35fa21bb9ddac37c639c39ba4b338c661b21479c02a308a388 | Python | 6,529 | 199 | """Plot the results of multidimensional scaling (MDS) applied on NSD-synthetic.
Parameters
----------
ncsnr_threshold : float
Lower bound ncsnr threshold of the kept voxels: only voxels above this
threshold are used.
zscore : int
Whether to z-score [1] or not [0] the fMRI responses of each vertex across
the trials... |
5d8fb09724edf348af2ad611de40d916832adcab297b2db6b9c547b96f636669 | Python | 6,530 | 196 | """transform_data
"""
import numpy as np
from nsdcode.nsd_output import nsd_write_vol, nsd_write_fs
from nsdcode.interp_wrapper import interp_wrapper as iw
from nsdcode.mapsurfacetovolume import mapsurfacetovolume
from tqdm import tqdm
__all__ = ['transform_data']
def transform_data(a1_data, sourcedata, tr_args):
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.