sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
d330a45e64f204b97641a9651e62875813cff846ffb3ac8105c3840c72563098 | Python | 4,811 | 99 | """
For evaluating trained models on genes that weren't included for train/val/test during train time
"""
from train_gtex import *
def load_test_gtex_datasets(row,test_genes,donor_pickiness,DATA_DIR):
assert donor_pickiness in ['all_donors','only_test_donors']
def instantiate_dataset(row,gene_list,donor_path,t... |
314ed8587bf7c55659731d125082c443845100219383f41ca2e9bca89f64fbcf | Python | 4,812 | 108 |
"""
Overlays brain area onto a registered sample brain without overlaying the atlas.
"""
import os
import numpy as np
from PyQt5 import QtGui
from lasagna.io_libs import image_stack_loader
# For the UI
from lasagna.plugins.ara import area_namer_UI
# For contour drawing
from lasagna.plugins.ara.ara_plugin_base impor... |
ea3152d8769711ebd7df5a4774be835557e8745493be3d28080c499ecb8e93e7 | Python | 4,812 | 112 | import numpy as np
from scipy import stats
from utils import Recorder, Q_nak
from mitochondria import Mito
import matplotlib.pyplot as plt
from figure_properties import *
dt = 0.1
def regular_spiking(sp_hz, spike_dur, q, t_start=150, t_run=1000, t_ca=5000, ca_fact=0.1):
time = t_run + t_start + spike_dur # ms t... |
c3616dcf4911666c2953fd89cca9956a929c414bb29314f9173f43d1b685b59f | Python | 4,813 | 142 | #!/usr/bin/env python
import os
import sys
import tqdm
import pdb
import numpy as np
import torch
from torch import nn
import torch.nn.functional as F
class RealGaborLayer(nn.Module):
'''
Implicit representation with Gabor nonlinearity
Inputs;
in_features: Input features
... |
7010bbb17f9cbd6491c667e631b71c3b5f6ccc188b9dfd227b8d0f0ee36dc06b | Python | 4,814 | 115 | import numpy as np
from typing import Dict, List, Tuple, Union
from bg_atlasapi import config, BrainGlobeAtlas
from napari.utils.notifications import show_info
from napari_dmc_brainmap.utils.atlas_utils import coord_mm_transform
def calculateImageGrid(x_res: int, y_res: int) -> Tuple[np.ndarray, np.ndarray, np.ndarra... |
81ca3f004269b00547fa1ebdea2713ce7eaf07971fa4373f51ff7dd197732075 | Python | 4,816 | 113 | # -*- coding: utf-8 -*-
from datetime import datetime, timedelta
from parser import Model
from parser.cmds.cmd import CMD
from parser.utils.corpus import Corpus
from parser.utils.data import TextDataset, batchify
from parser.utils.metric import Metric
import torch
import torch.nn as nn
from torch.optim import Adam
fr... |
e91e6165d3e8f73c550eda1fc3dea4d044002add9d172c74ad01ae98f403ae3c | Python | 4,816 | 132 | import numpy as np
from sklearn.metrics import mean_squared_error
from tqdm import tqdm
from argclz import AbstractParser
from neuralib.io import csv_header
from neuralib.suite2p import get_neuron_signal, sync_s2p_rigevent, SIGNAL_TYPE
from rscvp.util.cli.cli_output import DataOutput
from rscvp.util.cli.cli_selection ... |
5a5a0fe8f913209266e60ce9620e31c1faa39734493dad593cf4ed6b8af655d2 | Python | 4,817 | 117 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
from __future__ import annotations
from copy import copy
from pathlib import Path
from typing import Any
import torch
from ultralytics.models import yolo
from ultralytics.nn.tasks import PoseModel
from ultralytics.utils import DEFAULT_CFG, RANK
c... |
5067ab17c2401192633aa9bb4e16c602198896a914de852348682b956d648114 | Python | 4,818 | 164 | """Model factory to build different types of models."""
import torch
import numpy as np
from .mlp import SpikingMLP, SpikingEiMLP
from .vgg import SpikingVGG, SpikingEiVGG
from .resnet import SpikingResNet, SpikingEiResNet
in_channels_dict = {
'MNIST': 1,
'CIFAR10': 3,
'CIFAR100': 3,
'CIFAR10DVS': 2,... |
af0598d0663413ab3498de34be75348be0e3f6b12e28d5f4da0a6d22e9896cd1 | Python | 4,818 | 150 | """ Tracer classes to trace values of various arrays during gradient descent"""
from abc import ABC
import numpy as np
import matplotlib.pyplot as plt
def functor_extract_scalar_at_idx(idx):
def extract_scalar_at_idx(fw, arr_name):
return(np.asscalar(getattr(fw, arr_name)[idx]))
return(extract_scalar_... |
003860de10a5942016216632edb205fd1355eee64c24b59a3a5c7fa11db38bf7 | Python | 4,820 | 134 | # IMU (inertial motion unit) sensor data classes and methods
import copy
from .. import utils
from ..core import (
_analogsignalarray,
_epocharray,
) # core._analogsignalarray import AnalogSignalArray
class IMUSensorArray(_analogsignalarray.AnalogSignalArray):
"""
IMUSensorArray for storing and proc... |
546ef4f6cdb7200d99eef528df0d81af03471fe4e4d17cb41cc32b603d24fe39 | Python | 4,820 | 139 | # -*- coding: utf-8 -*-
"""
Make time series movie
The purpose of the following script is to make a movie to illustrate directly
the demeaned time series on the cortical surface.
"""
# python standard library inputs
import os
import shutil as sh
# external inputs
import numpy as np
import nibabel as nb
from nighres... |
9536f2b4619ffae49104cc98e2a5f2a92f2f47fd1337d0ffa2b4ba5f6a95b447 | Python | 4,820 | 162 | import importlib.util
import pytest
from magicgui import magicgui, use_app, widgets
params = ["qt"]
if importlib.util.find_spec("ipywidgets"):
params.insert(0, "ipynb")
# it's important that "qt" be last here, so that it's used for
# the rest of the tests
@pytest.fixture(scope="module", params=params)
def back... |
c464c39b7236291c280927e241672372e5337d7634b641c12900a53f1e4a2adc | Python | 4,821 | 129 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Given a bundle and MRDS metrics, compute the fixel-specific
metrics at each voxel intersected by the bundle. Intersected voxels are
found by computing the intersection between the voxel grid and each streamline
in the input tractogram.
This script behaves like scil_bu... |
ec064c18e3519a9a26dd21ccd6af13de63817d2583d76415b0516db9204ecc9a | Python | 4,821 | 99 | #encoding=utf-8
from __future__ import print_function
import sys
sys.path.append("../../")
import jieba
jieba.enable_parallel(4)
def cuttest(test_sent):
result = jieba.cut(test_sent)
for word in result:
print(word, "/", end=' ')
print("")
if __name__ == "__main__":
cuttest("这是一个伸手不见五指的黑夜。我叫孙... |
b3ca008ba2255be516729abed1dcfa90decebbee564acf3310440168699efd24 | Python | 4,822 | 93 | import itertools
import numpy as np
from brainscore_core.metrics import Metric, Score
from brainscore_vision.metric_helpers.transformations import apply_aggregate
class ErrorConsistency(Metric):
"""
Computes the error consistency using :meth:`~brainscore.metrics.error_consistency.cohens_kappa`
implement... |
5d5c848f8acd9d1e20860fa720e29fcafd8c5e0677ea0dffa3de766001be44cd | Python | 4,823 | 165 | # tifffile/setup.py
# Copyright (c) Christoph Gohlke
# SPDX-License-Identifier: BSD-3-Clause
# See LICENSE file in the project root for details.
"""Tifffile package Setuptools script."""
import re
import sys
from setuptools import setup
def search(pattern: str, string: str, flags: int = 0) -> str:
"""Return f... |
7c6c72f30cf17c7a1d8ae52c87a60a72704d85171925de9ebd5ab3032947fcda | Python | 4,823 | 173 | from __future__ import annotations
from pathlib import Path
from typing import Final
import pytest
from PySide6.QtCore import QPointF
from PySide6.QtCore import QTimer
from pytestqt.qtbot import QtBot
from labelme._app import MainWindow
from labelme._widgets._canvas import _CanvasMode
from ..conftest import close_o... |
afd5a2b465ec78bcce570b3c0fe37dc57b070cf2a7ad46e89d09a0716446105d | Python | 4,823 | 114 | """Demonstrates fitting Layers with multiple inputs, and Layer subclassing."""
import numpy as np
import matplotlib.pyplot as plt
from nems import Model
from nems.layers import WeightChannels, FIR, DoubleExponential
from nems.layers.base import Layer, Phi, Parameter
from nems import visualization
# Fast-running toy ... |
12f6a1ccb3bab259c46475972c435b941caf9ab6c35284949b2f59ce2b2251e4 | Python | 4,826 | 134 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Script to compute powder average (mean diffusion weighted image) from set of
diffusion images.
By default will output an average image calculated from all images with
non-zero bvalue.
Specify --bvalue to output an image for a single shell
Script currently does not t... |
8cea71f14321f203961a7e4bd1decc71e3ebaeab4a877fc8df172a8c41091ab6 | Python | 4,826 | 108 | # /------------------------------------------------------------------------------+
# | 2-AUG-2022 |
# | Copyright (c) Bone Imaging Laboratory |
# | All rights reserved ... |
5723e8ec4cbbc26692d2ede60aae0e234ce821550e793db821a21b479874e822 | Python | 4,827 | 138 | # -*- coding: utf-8 -*-
# external inputs
import numpy as np
from numpy.fft import fftshift
def get_bandpass_filter(nx, ny, fovx, fovy, kcut_low=0, kcut_high=1,
apply_fftshift=False, k_fwhm=0, theta_fwhm=0, theta1=0,
theta2=180):
"""Get bandpass filter.
... |
9304afffe5f6388288c17090ceda204df337f1fffa3385db688cd3cd41280c12 | Python | 4,830 | 143 | #!/usr/bin/env python
import argparse
import sys
from pathlib import Path
import imgviz
try:
import lxml.builder # type: ignore
import lxml.etree # type: ignore
except ImportError:
print("Please install lxml:\n\n pip install lxml\n")
sys.exit(1)
sys.path.insert(0, str(Path(__file__).resolve().... |
1c42f84bb9612b78f62566e97c1ee4e078ff44bdc4641e7740fe9e0b9c865cb4 | Python | 4,831 | 142 | import torch
import torch.nn.functional as F
from torch import Tensor
import numpy as np
import torchvision.ops.boxes as bx
from .boxes import pairwise_box_iou, pairwise_generalized_box_iou
__all__ = ['reduce_loss', 'log_margin_loss', 'margin_loss', 'r1_regularization', 'iou_loss']
def reduce_loss(x: Tensor, reducti... |
7a0d006724d2a61fe61e53ee1fd1a58362caf0da90121992aeae8123fbf24b6b | Python | 4,831 | 158 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
from typing import TypeVar
from allauth.account.models import EmailAddress
from django.db import transaction
from django.db.models import Model
from django.db.models.signals import m2m_changed, post_delete, post_save, pre_delete
from django.dispatch... |
9fb13f4538206a0e24d9d20499f2e74b65e4d68d9d73f5fd4034d7d78bed7311 | Python | 4,832 | 135 | """Tests for per-exchange artifact attribution (ui.artifacts)."""
import json
import os
from ui import artifacts
def _touch(path, mtime=None, content="x"):
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(content)
if mtime is not None:
os.utime(path, (mtime, mtime))
return path... |
b1f9280cacccb5fe31e6f64b5b1582472582a502fec5d6ce0d626702971acdbd | Python | 4,832 | 152 | #!/usr/bin/env python3
import argparse
import os
import numpy as np
import pandas as pd
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
plt.style.use('bmh')
def read_csv_auto(path):
"""
尝试用 pandas 读取 CSV 或 TXT,返回 ndarray。
If file missing or empty -> raise.
"""
if not os.... |
763aa8fd817bd3ef0cc216830114dd566be44ef249be6abdb3d521f7f5445f16 | Python | 4,834 | 127 | import numpy as np
from keras import backend as K
from keras import initializations
from keras.layers import Layer, Input, Embedding, merge
class FixedEmbedding(Layer):
"""Embedding with fixed weights.
Modified from keras/layers/embeddings.py in Keras (http://keras.io).
WARNING: this is experimental and... |
b103905f183f158ef05cb980b47dedc3140704bd98ce30a1b6412fc41683e008 | Python | 4,834 | 122 | #!/usr/bin/env python
#keras version: keras-1.2.0
import os
import sys
import keras
import datetime
import numpy as np
import hickle as hkl
from sklearn import metrics
from keras.models import Model, Sequential
from keras.layers import Input
from keras.layers import Convolution2D, MaxPooling2D, Flatten
fr... |
673632b7387d7aa6e501f61e8448833872784f2cb394bb2293e0d5979f576c35 | Python | 4,835 | 171 | """
This module runs roc analysis on given windows of time.
"""
import matplotlib.pyplot as plt
import os
from utils.plots import beutify
def plot_trial_type(
ax, time_bins, firing_rates, cluster, trial_type, color, line_style=None
):
if line_style is None:
if "actor" in trial_type:
line_... |
82933b5103d37884978043dbba1ffaaf4c7f530d75990f802ec7f35fd1673f61 | Python | 4,835 | 152 |
#!/usr/bin/env python3
postdock_two_conf.py
End-to-end post-processing for two-conformer docking (apo + CNA).
What it does
------------
1) Parse all *.log files in APO_DIR and CNA_DIR to extract best affinities (kcal/mol)
2) Intersect ligands present in both conformers and compute Mean & SD
3) Write two CSVs:
- <p... |
9641b552730743eaadff415ce6cf393d57ef713f949732ff819286f0011e09f9 | Python | 4,835 | 159 | # Copyright 2017 Calico LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
c012a23b819c93b9dab895b6036f75ed545c6c9a51c78bc513b3aa1362b84ad9 | Python | 4,835 | 141 | #!/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... |
40517e92522e0b12ca9cb35a56ffc3e13fdcc8bdc03a3625b0cc42d8d3691708 | Python | 4,836 | 160 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
"""
import cv2
import numpy as np
_LARGE_MASK_AREA_THRESH = 120000
def apply_colormask(image_cv, mask, color_rgb, alpha=0.5):
"""
Overlays a colored mask onto an image with specified transparency.
Parameters
----------
image_cv : np.ndarray
... |
a67ca91e7b244e1c82d6ef028f5c2c030ff40e54406ec4b868d444e666ddfc4b | Python | 4,836 | 146 | from __future__ import annotations
import io
from pathlib import Path
import numpy as np
import PIL.Image
import pytest
import tifffile
from labelme._label_file import read_image_file
def _make_image(tmp_path: Path, /, *, filename: str, mode: str) -> Path:
channels = 4 if mode == "RGBA" else 3
arr = np.ran... |
17e7defc7ac497666a3d8b6ea01433fd7aede8b052196acde74c407104e88a5a | Python | 4,840 | 120 | """
Defines the mapping from task types to the task implementation
"""
from . import simple_task
from . import simple_touch_task
from . import simple_touch_and_look_task
from . import suppressed_reach_task
from . import delayed_reach_task
from . import delayed_saccade_task
from . import delayed_reach_and_saccade_task
... |
587965858cfd71196bbe24bde974a292a4a851f888a8cba4ce41da13a5531083 | Python | 4,840 | 206 | # The ImpedanceFitter is a package to fit impedance spectra to
# equivalent-circuit models using open-source software.
#
# Copyright (C) 2018, 2019 Leonard Thiele, leonard.thiele[AT]uni-rostock.de
# Copyright (C) 2018, 2019, 2020 Julius Zimmermann,
# julius.zimmermann[AT]un... |
5501becafaccf653e734ac1c57c40488c116405210fe7476cce389e13a254c99 | Python | 4,844 | 106 | import torch
def clone_weight(projection, source=None, sign=1, scale=1, source2=None, transpose=False):
"""
Force a projection to exactly copy the weights of another projection (or product of two projections).
"""
if source is None:
raise Exception('clone_weight: missing required weight_constr... |
6d5938ae02a4309fcedab94231a78a2857a51df67b776087d03065288fe60e05 | Python | 4,844 | 112 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import tempfile
from scilpy import SCILPY_HOME
from scilpy.io.fetcher import fetch_data, get_testing_files_dict
fetch_data(get_testing_files_dict(), keys=['commit_amico.zip'])
tmp_dir = tempfile.TemporaryDirectory()
def test_help_option(script_runner):
r... |
c1e7e9dcf09feaf4f2a8840480a26db2fee169e1d3ce97f3b73b7cb548ba30a5 | Python | 4,844 | 150 | from __future__ import annotations
import argparse
import socket
import json
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
from importlib.resources import files
from pathlib import Path
from typing import Any
from chemgraph.academy.observability.event_log import read_events
from chemgraph.academ... |
89b2b7d0f1629231f0eaed9409372ab6171ad1bd60b42fd5af59d47b6411b036 | Python | 4,845 | 145 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import textwrap
from drf_spectacular.utils import (
OpenApiParameter,
OpenApiResponse,
OpenApiTypes,
extend_schema,
extend_schema_view,
)
from rest_framework import mixins, viewsets
from rest_framework.exceptions import NotFound
... |
ad684e26b0bc37a2d6281806a7637a62252b14533c120ef4b0d16cf30ff3c1c6 | Python | 4,846 | 144 | """
Join two sets of intervals using their overlap as the key. The
intervals MUST be sorted by chrom(lexicographically),
start(arithmetically) and end(arithmetically). This works by simply
walking through the inputs in O(n) time.
"""
import math
from bx.intervals.io import GenomicInterval
from .quicksect import Int... |
fb57ee5707326a27c658b46c3d56394b590e9adda9ec6109e1e5221f8123575f | Python | 4,846 | 95 | # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file '/media/lg/disk2/PycharmProjects/ISAT_with_segment_anything/ISAT/ui/plugin_manager_dialog.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 e... |
b1a0e67e69b18937082bd60cc2217f7b5e98b99e53ce6d2428c1ede5399abec1 | Python | 4,847 | 142 | from tqdm import tqdm
from dataset import get_transfer_data
from model import BotGAT
import json
import torch
import torch.nn as nn
from torch_geometric.loader import NeighborLoader
from sklearn.metrics import accuracy_score, f1_score
import random
dataset = 'Twibot-22'
idx = json.load(open('idx.json'))... |
468d94f82d46035d5c2557cda74a69b112394c63079ddf5d50c2ea5d028ef8e4 | Python | 4,848 | 120 | import os
import yaml
import torch
import random
import models
import argparse
import numpy as np
import torch.nn as nn
from utils.utils import *
from scipy.io import loadmat
import matplotlib.pyplot as plt
from torch.utils.data import Dataset, DataLoader
from torch.utils.tensorboard import SummaryWriter
... |
66a731d683cac818e0af8f4f82a679aaf81cbb7de9048a8f0df33433324ab3bf | Python | 4,848 | 152 | import cloudfiles
import os
import marshmallow as mm
import sys
import secrets
class OutputFile(mm.fields.Str):
"""OutputFile :class:`marshmallow.fields.Str` subclass which is a path to a
file location that can be written to by the current user
(presently tested by opening a temporary file to that
... |
f1aa96a863ef94c63df02a8ff0a447255bb6db9eed483724812a24aa2f41c446 | Python | 4,848 | 137 | """Writes that either land whole or not at all.
Everything the pipeline writes, it used to write in place: open the final path,
stream bytes into it, hope. That is fine until a run is interrupted — Ctrl-C, a
cluster job hitting its wall clock, a laptop lid — and then the file that was
mid-write is left truncated, at i... |
b33684f8885f30b036a5a047fee86f7d0a83fb69ccf72789f60595855710992e | Python | 4,849 | 110 | #CMU Multimodal SDK, CMU Multimodal Model SDK
#Multimodal Language Analysis in the Wild: CMU-MOSEI Dataset and Interpretable Dynamic Fusion Graph, Amir Zadeh, Paul Pu Liang, Jonathan Vanbriesen, Soujanya Poria, Edmund Tong, Erik Cambria, Minghai Chen, Louis-Philippe Morency - http://www.aclweb.org/anthology/P18-1208
... |
685c88cf6bb9533076addb21d18fedbede2d30d467568c366696614fed373238 | Python | 4,852 | 141 | # coding=utf-8
from typing import List, Optional, Tuple, Union
import numpy as np
import tensorflow as tf
import tensorflow.keras.layers as tfkl
from deepreg.model import layer_util
from deepreg.model.backbone.u_net import UNet
from deepreg.registry import REGISTRY
class AffineHead(tfkl.Layer):
d... |
6c8bde465b6802f55dc777b646c586fda53e82caabf698eb53dc5abc31fefd41 | Python | 4,852 | 152 | import json
import numpy as np
import pytest
import tifffile
from napari_dmc_brainmap.preprocessing import preprocessing_tools
def _write_section(root, channel, name, image):
channel_dir = root / "stitched" / channel
channel_dir.mkdir(parents=True, exist_ok=True)
tifffile.imwrite(
channel_dir / ... |
177020c71ad1a95e15eeea3eb92055383d4fdbaa4c47b15f5a9737a731801707 | Python | 4,853 | 141 | # Copyright (C) 2022 Intel Corporation
# Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import re
import textwrap
from drf_spectacular.authentication import BasicScheme, SessionScheme, TokenScheme
from drf_spectacular.extensions import OpenApiAuthenticationExtension, OpenApiFilterExtension
from dr... |
e2d0e4646d16b4d9f8e80b71e977ade2140a6da1e0d0775d6b21164ac628ad30 | Python | 4,853 | 128 | #!/usr/bin/env python3
import pandas as pd
import numpy as np
import gzip
import pickle
import sys
import argparse
import os
def choose_variant_annotation(csq_string, variant_annotation_rank_dict, gene_ix, conseq_ix):
"""Parse lowest ranking consequence and gene ID from CSQ string"""
minrank = len(variant_ann... |
ebcbc3fdc98b4eacb15040bbfd89ab49baafe86ec230956411d76f43ab1b0055 | Python | 4,853 | 92 | #!/usr/bin/env python
import chromatics
import numpy as np
import pandas as pd
import sklearn.externals.joblib as joblib
def generate_average_signal_features(chunk_df, region, dataset):
assert (chunk_df[region + '_end'] > chunk_df[region + '_start']).all()
region_bed_columns = ['{}_{}'.format(region, _) for ... |
051a1673c03762977742723edaf38636bb01d9216881ba3bd26082d6b23d4a67 | Python | 4,854 | 141 | # Copyright 2014 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 math
from nupic.algorithms import anomaly_like... |
1bd2ae095cee2b6c2fdbc33394ec439a8ab32acd7259e3bf2ed1560c5243d048 | Python | 4,854 | 134 | from brainscore_vision.model_helpers.check_submission import check_models
import functools
from transformers import CvtForImageClassification
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from PIL import Image
import numpy as np
import torch
"""
Template module for a base model submiss... |
35b3431e1637330dbd97eb2e695cba24d7f9b9ba65854c44442d2e1f4096fba8 | Python | 4,855 | 150 | # Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... |
79ed523eaa5840cb85b804a963d490ce78dd2d3fd8fa409461d15a0e3e736952 | Python | 4,855 | 116 | """Shared utilities for attaching a resampling-based standard error to a Score.
Proposed home: ``brainscore_vision/metric_helpers/bootstrap_error.py``.
A benchmark's reported score is one realisation drawn over a finite set of stimuli
and subjects. The ``error`` attribute records how much that score would move under
... |
b04ac248e3dd3a48b2d5c6ca49cf6d037806c2159e0b9c8d7b34980abae1405e | Python | 4,855 | 169 | # -*- coding: utf-8 -*-
"""Surface labels."""
import numpy as np
from ..io.affine import apply_affine_chunked, vox2ras_tkr
from ..surface.mesh import Mesh
__all__ = ["label_border", "label_dilation", "label_erosion", "roi_fov", "roi_sphere"]
def label_border(arr_label, vtx, fac):
"""This function returns borde... |
baf7a10d7bf6edcdea461bb4582d628ffc0468b758d8e9814cf4fbd03f510c57 | Python | 4,855 | 130 | import os
import argparse
import logging
from datetime import datetime
import step1_dataimport.step1_1_main as step1_1_dataoverview
import step1_dataimport.step1_2_main as step1_2_filtered_import
import step2_defacing.step2 as stp2
import step3_1_get_features.step3 as stp3_1_features
import step3_2_manual_labeling.s... |
21f70177720346f8083c4a27caaf65744ca61ec595c3cfde8c79188b74909ce0 | Python | 4,856 | 153 | import os
import tarfile
from abc import ABC
import pandas as pd
import seisbench
import seisbench.util
from .base import WaveformBenchmarkDataset
try:
from huggingface_hub import hf_hub_download
except ModuleNotFoundError:
hf_hub_download = None
class CWABase(WaveformBenchmarkDataset, AB... |
940472259cdf3d9f65416f2ad2861a5638c4c7b29887a7fffb9bf209781d2fde | Python | 4,856 | 181 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
from __future__ import annotations
import io
import json
import warnings
from collections.abc import Iterable
from typing import Any
import tqdm
import urllib3
from cvat_sdk import exceptions
from cvat_sdk.api_client.api_client import ApiClient, E... |
c58f1550fc8fd150964052cbb0525bab565973beac55ae9971034a65e32950dc | Python | 4,856 | 163 | #!/usr/bin/env python3
import arbor as A
from arbor import units as U
import pandas as pd
import seaborn as sns
# Construct chains of cells linked with gap junctions,
# Chains are connected by synapses.
# An event generator is attached to the first cell in the network.
#
# c --gj-- c --gj-- c --gj-- c --gj-- c
# ... |
3d7998dd11632426db5ae84fab0346fb63f5b82575e03ef64f85fac1970668a3 | Python | 4,857 | 158 | # -*- coding: utf-8 -*-
"""
10-折交叉验证(仅回归) + 残差可视化
运行:
$ python -m src.train.cross_validation
"""
from __future__ import annotations
import csv, json
from pathlib import Path
import numpy as np
import torch
from sklearn.model_selection import KFold
# matplotlib 仅用于保存图,Agg 后端适合服务器
import matplotlib
matplotlib.use("Agg... |
3c62d25cf9bafc0eeb8188dc63fe0080fc9727ae4a45c1513e29f3107a1fc63b | Python | 4,858 | 139 | #!/usr/bin/python
#
## @file
#
# Handles notifications (by e-mail) about the system status.
#
# Hazen 06/13
#
from email.mime.text import MIMEText
import smtplib
import traceback
## Notifier
#
# The notification class.
#
class Notifier(object):
## __init__
#
# @param smtp_server The ... |
7e1a00f6357646cd309f27823c48f8304b110e6bf56cff3528aaac6ea93abcf5 | Python | 4,858 | 157 |
import pandas as pd
from sklearn.neighbors import NearestNeighbors
def cal_niche(df, group, group_col='celltype', radius=15):
"""calculate niche component
Parameters
---------------------------
df: pd.DataFrame
dataframe contain coordinates and group information
group: str
group u... |
78c8e181e15313f560fbc33d38027943eb36e52d9446750c4ba379e77553be0e | Python | 4,859 | 127 | """Script to translate annotation as lines for pearling to images for training."""
#%% Imports
import numpy as np
import csv
from pathlib import Path
import tifffile
from shapely.geometry.linestring import LineString
from typing import List, Tuple
import matplotlib.pyplot as plt
import cv2
from tqdm import tqdm
from ... |
a35405efa362c4d2050c7f641293277e209a131614c09f34bb2bd10a9f98d805 | Python | 4,859 | 134 | '''
CH4Cl
'''
import numpy as np
import sys
def intro():
print("""
SHORT List of potential energy surfaces for CH4Cl:
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 a... |
5632c2601e6e6de55b8927afad51e9de1774cd47e971509c9d03910842ef8c84 | Python | 4,860 | 114 | import numpy as np
from dipy.core.gradients import gradient_table
from src.wrappers.OsipiBase import OsipiBase
from src.original.fitting.IAR_LundUniversity.ivim_fit_method_segmented_3step import IvimModelSegmented3Step
class IAR_LU_segmented_3step(OsipiBase):
"""
Bi-exponential fitting algorithm by Ivan A. Ra... |
4672fde8cc1a03b28ea51e7c01cff531f845e1e00b0d1f52e2169b19c43d93c0 | Python | 4,861 | 126 | # Copyright (C) 2019-2022 Intel Corporation
# Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import shutil
import datumaro as dm
from cvat.apps.dataset_manager.bindings import GetCVATDataExtractor, detect_dataset
from cvat.apps.dataset_manager.util import make_zip_archive
from cvat.apps.engine.mo... |
96ed1b710f0e4a838d6211812ea89e7e4117784e9436cb6bcc05c549ab771551 | Python | 4,861 | 145 | '''
CH4CN
'''
import numpy as np
import sys
def intro():
print("""
SHORT List of potential energy surfaces for CH4CN:
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 a... |
c968bb31bd70ec89ae455381bca9942970861030440ebe6f9a831dacb25fc405 | Python | 4,861 | 99 | #encoding=utf-8
from __future__ import print_function
import sys
sys.path.append("../")
import jieba.posseg as pseg
def cuttest(test_sent):
result = pseg.cut(test_sent)
for word, flag in result:
print(word, "/", flag, ", ", end=' ')
print("")
if __name__ == "__main__":
cuttest("这是一个伸手不见五指的黑夜。... |
d3f68e666d56cdc9cbb60374b2bce68d9d9673b27afa41a8714f7efd4d152c9d | Python | 4,861 | 130 | import pickle
from pathlib import Path
import h5py
import seisbench
from .base import WaveformBenchmarkDataset, WaveformDataWriter
class TXED(WaveformBenchmarkDataset):
"""
TEXD dataset from Chen et al.
train/dev/test split defined in SeisBench.
"""
def __init__(self, **kwargs):
citat... |
d64657c7a5c3a13411fa3c6810073c94586de79da799848cd41b9ca8bab3b957 | Python | 4,861 | 154 | from pathlib import Path
from typing import Callable, Optional
import dolfin as df
import nibabel
import numpy as np
import pyvista as pv
import scipy
import simple_mri as sm
from dolfin import inner
from panta_rhei import FenicsStorage
from gmri2fem.utils import apply_affine, nan_filter_gaussian
from i2m.vtk2mri imp... |
4c6d23a6a526dc551a4e2698e7fa11b9d52b317028bc43050c2e1d414fde6cf2 | Python | 4,862 | 91 | """A module that contains processors for computing the graph Laplacian, which is mainly used for spectral embeddings."""
import typing
import numpy
import scipy.sparse
from corelay.processor.base import Processor
def a1ifmat(matrix: numpy.ndarray[typing.Any, typing.Any] | numpy.matrix[typing.Any, typing.Any]) -> n... |
6aa765033f7090d423fb61351bb8981f0b58c3d478eacce43321ba5460109081 | Python | 4,862 | 143 | import random
from torch.utils.data.sampler import Sampler
import torch
import torch.nn as nn
from torch.nn.functional import gumbel_softmax
from queue import Queue
import numpy as np
def invert_sigmoid(x):
return x.log() - (1-x).log()
class RandomCycleIter:
def __init__ (self, data, test_mode=False):
... |
8943aee4f7ed56db555e45ac238281458954bc473026caa8922f71510ef57239 | Python | 4,862 | 130 | '''
NH4
'''
import numpy as np
import sys
def intro():
print("""
SHORT List of potential energy surfaces for NH4:
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 g... |
c588672f53efa6d1d7f0242da9923e2641d62075809f94dc79879e93716109f1 | Python | 4,862 | 139 | # Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... |
fab3ddbdcfd617540156d5ed9e3780c6b62ec4020c8b10f1ac097ab34a5b321b | Python | 4,862 | 100 | #encoding=utf-8
from __future__ import print_function
import sys
sys.path.append("../../")
import jieba
jieba.enable_parallel(4)
import jieba.posseg as pseg
def cuttest(test_sent):
result = pseg.cut(test_sent)
for w in result:
print(w.word, "/", w.flag, ", ", end=' ')
print("")
if __name__ == "... |
8390c971d4d6928f7a037688410040102eb69228a09fca4fc023318d7bebaf04 | Python | 4,863 | 138 | """
This module contains functions for finding sessions and spike directories.
"""
import os
import pandas as pd
from pathlib import Path
from utils.LoadSession import findrootdir
def load_subject_names():
rootdir = findrootdir()
subject_names_path = f"{rootdir}/subject_names.csv"
return pd.read_csv(subj... |
da8e87e6a20737963c3ca0e03312a8510235f3adbf8053e70fc7b31d9c622248 | Python | 4,863 | 91 | from qtpy.QtGui import QPixmap,QImage
from napari_dmc_brainmap.registration.sharpy_track.sharpy_track.view.ViewerGeneral import ViewerGeneral
from qtpy.QtWidgets import QLabel
import cv2
class ViewerLeft(ViewerGeneral):
def __init__(self,regViewer) -> None:
super().__init__(regViewer)
self.labelCon... |
7f0de765b21ea3b436a30e11289e99da0d98ce72dae0177327b4cec4662311c8 | Python | 4,865 | 91 | from PyQt5.QtGui import QPixmap,QImage
from napari_dmc_brainmap.registration.sharpy_track.sharpy_track.view.ViewerGeneral import ViewerGeneral
from PyQt5.QtWidgets import QLabel
import cv2
class ViewerLeft(ViewerGeneral):
def __init__(self,regViewer) -> None:
super().__init__(regViewer)
self.labelC... |
b7bdbd0328115a2b70e4b4323ab4f46492bc289c23d5cb59491b9aec4ffccb44 | Python | 4,865 | 149 | from taskqueue import queueable
from skeleton_keys.cmds import process_morphology_features
from skeleton_keys.cmds.layer_aligned_swc import (
LayerAlignedSwcSchema,
main as layer_align_main,
)
from skeleton_keys.cmds.upright_corrected_swc import (
UprightCorrectedSwcSchema,
main as upright_main,
)
from ... |
82aecdda76ca60219beab06c1a25937d925d742e281ff8bac720582fd08b24c4 | Python | 4,868 | 125 | # Main keywords and parameters obtained from https://wiki.fysik.dtu.dk/ase/_modules/ase/calculators/nwchem.html
# Parameters for NWChem calculator in CompChemAgent
from typing import Optional, Union, Dict
from pydantic import BaseModel, Field
from ase.calculators.nwchem import NWChem
class NWChemCalc(BaseModel):
... |
c82c7bee88dd753253ebe585197565cc2b38aa92e4634bb5dadd1c237a7d4866 | Python | 4,868 | 149 | import argparse
import os
import os.path as osp
import time
import numpy as np
import torch
import torch.nn.functional as F
import pandas as pd
import json
import ijson
import torch_geometric.transforms as T
from torch_geometric.nn import ChebConv, GCNConv, Linear # noqa
from tqdm import tqdm
from sklearn.metrics impo... |
68d63bf0f60b1efea2777ee52730618100970eba11074654346a1a6826b9867a | Python | 4,869 | 134 | """Structural tests for degree-preserving null models (``null_models.py``)
and the normalized participation coefficient built on top of them
(``network_metrics.participation_coef_norm``).
Run from the repo root::
uv run python python/test_pipeline_null_models.py
These functions are stochastic (Maslov-Sneppen edg... |
3b4d75d0a8467fcc58496b1a13801c6509568f4f7ea84576325775eaa02ac342 | Python | 4,870 | 129 | import time
import numpy as np
from numpy import linalg
import ladyns.optimize.core as core
def fit(observations, lambda_glasso, lambda_ridge=0,
ths = 0.001, max_iter = 1000,
ths_glasso = 1e-8, ths_lasso = 1e-10, verbose = False,
weight_init = None, Omega_init = None):
# check on o... |
9d15a05dbb25b8a8fe4b75cd03b4d607215357e6cc4cd0d8f94e196e973670a9 | Python | 4,870 | 151 | """
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... |
a885cd061bd22945a5cb450d3cf537633d1352ffa1bdde47e6d9223557ef8925 | Python | 4,870 | 131 |
import pandas as pd
import numpy as np # fundamental package for scientific computing, handles arrays and math
import matplotlib.pyplot as plt # standard Python plotting library
from matplotlib.ticker import MaxNLocator # so we can force integer tick labels later
import copy
import tdt
from tdt import read_block, epoc... |
2ec97d57598c6287c76de3a1e0406d0dfd724cabae334674d3ab3762480181b4 | Python | 4,872 | 99 | #encoding=utf-8
from __future__ import print_function
import sys
sys.path.append("../")
import jieba.posseg as pseg
def cuttest(test_sent):
result = pseg.cut(test_sent, HMM=False)
for word, flag in result:
print(word, "/", flag, ", ", end=' ')
print("")
if __name__ == "__main__":
cuttest("这是一... |
b6669dfffee2dbe835b5c8062483ec55ab8d6a9bd4624066119dbe43d8a9c757 | Python | 4,872 | 115 | import argparse
import utils
import keras
from keras.models import load_model
from os.path import join
import numpy as np
import gc
'''
calculate standard deviation of ensemble predictions for train/test/val data
for MPRAnn models
'''
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("... |
f7c2dafd010095a2399e441a4ed82d587140d2c3c67016e33918827d51b514e1 | Python | 4,872 | 120 | #! /usr/bin/env python
"""`morphometrics fetch_example` - download a dataset for testing the pipeline.
Two sources:
zenodo (default): a small (~tens of MB) cropped tomogram + segmentation that
exercises the whole pipeline, including density sampling / thickness /
refinement. Extracts a ready-to-run `surface_... |
4466612fad8f11cf4b94c79fc3dd0a6270176787d494b44bd38d87ce00cafd27 | Python | 4,874 | 109 | """
Find the neighbors of each vertex.
"""
def neighbor_info(a,b,c,x,y,z,subjects_dir,subject,hemi,surface,mesh):
import numpy as np
import os
neighbors_unsorted = [set() for _ in range(len(x))]
triangles_unsorted = [set() for _ in range(len(x))]
def add_neighbor(neighbors, whichtri... |
89e8b2551194a810b2ed4f9c50d007db6ac84ae8b92be42c863ffb8c0f81c0e0 | Python | 4,875 | 186 | """Utilities for handling IEEE 754 floating point special values
This python module implements constants and functions for working with
IEEE754 double-precision special values. It provides constants for
Not-a-Number (NaN), Positive Infinity (PosInf), and Negative Infinity
(NegInf), as well as functions to test for th... |
b4a2322022893915b1fbc4d82e65f69128e6a1be1ee1d658fb9cb2dfb93305e7 | Python | 4,875 | 138 | from __future__ import print_function as _, division as _
import numpy as np
from matplotlib import pyplot as plt
import histograms as hist
def isi_histogram_plot(middles, filename,**hists):
f = plt.figure()
f.suptitle('isi histograms, no correction ' + filename)
f.canvas.set_window_title('isi histogram ' ... |
9ef5aa63328348c6be88826c9cbe34005ce269bb267baaa4aa19395f18f7a735 | Python | 4,876 | 81 | import os
import json
import shutil
import subprocess
from nipype.interfaces.base import BaseInterface, BaseInterfaceInputSpec, TraitedSpec, File, Directory, traits, CommandLineInputSpec, File, TraitedSpec, CommandLine, Directory
from traits.api import Directory, Str, List
from cvdproc.bids_data.rename_bids_file impor... |
a26cee2383ec11775c99c0cd9ec1814fbc960bfde9b6eeb467b13452c376585e | Python | 4,876 | 124 | import numpy as np
import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection
import TwoD_fun
import brainpy.math as bm
#set default ramndom seed for reproducibility
bm.random.seed(1)
#set backend to cpu
bm.set_platform('cpu')
xlabel = ['Traveling wave', 'Super-diffusion','Brownian-diffusion','... |
c2387aa072e036e8c1e8f629078f301ff406f387daac92c3620137c4c4c5090f | Python | 4,876 | 112 | import os
import pandas as pd
import subprocess
from nipype import Node, Workflow
from nipype.interfaces.utility import IdentityInterface, Merge, Function
from cvdproc.pipelines.smri.brainage.brainage_nipype import BrainAgeR
class BrainAgePipeline:
def __init__(self,
subject: object,
... |
4093ebc5a62cf7cb19542b171391089514348a41c05cf51e46894c762d97f4cb | Python | 4,878 | 234 | #! /usr/bin/env python
# aponteeduardo@gmail.com
# copyright (C) 2016
''''
Graphical tools
'''
import numpy as np
from scipy.integrate import cumtrapz
from scipy import stats
from . import containers
from . import wrappers
def lcosh(x):
''' Log of cosine hyperbolic '''
# if np.abs(x) > 10.0:
# ... |
7663be6d20dcf54a240af879717fd484f99dffa0f9c4251db67d007e8f2967b7 | Python | 4,878 | 118 | import argparse
import os
import numpy as np
from tqdm import tqdm
import torch
from torch.utils.data import DataLoader
from utils.dataset import InferDatasetFromFolder, save_nii_series
from model.model import Generator
# 定义命令行参数
def args():
parser = argparse.ArgumentParser(description='模型推断:以三维的nii文件作为输入,输出指定倍率... |
992fd073f25b63f63e3a0187f2e42dad4ce9fda5657c27ebc11d738b1199faf0 | Python | 4,878 | 156 | """Loads data stored in the formats used by the Neuralynx recording systems."""
# Adapted from nlxio written by Bernard Willards <https://github.com/bwillers/nlxio>
import numpy as np
from .. import auxiliary
def load_position(filename, pixels_per_cm=None):
"""Loads videotracking position as a nelpy PositionAr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.