sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
e58b6f17e3ac7f268c4e9682c1eaabd05400b034cd4bd308330c2df80d1b0882 | Python | 2,113 | 80 | """
Tests phys2bids.py
"""
import json
import os
from pytest import raises
from phys2bids import phys2bids
def test_print_summary(tmpdir):
test_filename = "input.txt"
test_ntp_expected = [
10,
]
test_ntp_found = 5
test_samp_freq = 0.2
test_time_offset = 0.8
test_outfile = tmpdir... |
7599665382200a4a6500d9f8a0e07dcbd1496e29d6736fecf4663995b260588f | Python | 2,115 | 82 | import numpy as np
import sys
import os
def get_traj_scale(traj):
diff = traj[1:] - traj[:-1]
dr_2 = np.sum(diff ** 2, axis=1)
scale = np.sqrt(np.mean(dr_2))
if scale == 0:
return 1.0
else:
return scale
def sample_sphere(dim):
X = np.random.normal(0, 1, dim)
X /= np.linal... |
2b35634f688524d2c17bac65fcef72b9a73895fc8ef145e488aeb3961e93262b | Python | 2,116 | 60 | # Copyright 2022 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... |
c7f0691e0f7725ad9dbe923943ecca188cd87a016a4fcab0fa271e15fa10ffda | Python | 2,116 | 61 | # -*- coding: utf-8 -*-
# Auxiliary preprocessing methods.
# COPYRIGHT: TU Delft, Netherlands. 2021.
import glob
import h5py
import numpy as np
class DataRescaler():
"""
Creates and object that contains the rescaling factors
to get the data in the interval [0,1].
*path: string path to the data. Recomm... |
f63b24d7fd87188c50844236e65fdd6cc6ea251e432d6e0a7afeeaaeaac44ba3 | Python | 2,116 | 62 | from OR import or_params, or_ini
from neuron import orn_params, orn_ini, pn_params, pn_ini, ln_params, ln_ini
from synapse import n_orn_pn, orns_pns_ini, orns_pns_post_params, n_orn_ln, orns_lns_ini, orns_lns_post_params, pns_lns_ini, pns_lns_post_params, lns_pns_g, lns_pns_post_params, lns_lns_g, lns_lns_post_params
i... |
af7f052bd5ef81c5abf0b03d019c5747be1ce0f5bdcc99306c7b3ec829129f2e | Python | 2,117 | 77 | """
Stub file for a guaranteed safe import of duecredit constructs: if duecredit is not available.
To use it, place it into your project codebase to be imported, e.g. copy as
cp stub.py /path/tomodule/module/due.py
Note that it might be better to avoid naming it duecredit.py to avoid shadowing
installed duecredit.... |
ff2a9aa9d8f2bbfc37078ac40e2659f8ca64498b6ac381757a5cb6571bd20433 | Python | 2,117 | 76 | """
Functionality for handling complex-valued spatial data
"""
from copy import deepcopy
import torch
from torch import nn
import torch.nn.functional as F
def CGELU(x: torch.Tensor):
"""Complex GELU activation function
Follows the formulation of CReLU from [1]_.
Applies GELU to real and imaginary parts ... |
4e9316d3a9b353f47de109d684acc56d459f2b8b450b00d9ca72e010a36eb0da | Python | 2,119 | 64 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2014 Gaurav Kumar. Apache 2.0
# 2018 Nagendra Kumar Goel, Saikiran Valluri, GoVivace inc., Avaaya
# Merges unique words from Spanish Fisher, Gigaword and the LDC spanish lexicon
from __future__ import print_function
import sys, re
import json
import cod... |
cd779c05001835249666ca635ec7b3dc73d25784d855acdd92e074672fa34535 | Python | 2,119 | 56 | import sys
sys.path.append("/Volumes/GoogleDrive/My Drive/python_code/connectome_tools/")
import connectome_tools.process_skeletons as proskel
import pandas as pd
from tqdm import tqdm
import numpy as np
import networkx as nx
connectors = pd.read_csv('axon_dendrite_data/splittable_connectors_all_mod.csv', header=0,... |
e1ce3c0e9c7febec69f72d953753f744b39a99f4798d82e1df558f016246f7b6 | Python | 2,119 | 86 | import gzip
import sys
## rewrites lifted RSIds and SNPMap using a reference set
infile = sys.argv[1] # SNPMappings.txt.gz after liftover
infile2 = sys.argv[2] # Reference SNPMappings.txt.gz (e.g. from dbSNP)
infile3 = sys.argv[3] # SNPs.txt.gz after liftover
outfile = sys.argv[4] # output file prefix
chrposto... |
a2763fb5a02f490a8a95955263349250f1fc5f1b8f32dc0d3d9904f931a3bdb4 | Python | 2,120 | 50 | # Copyright 2020 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... |
bfa1693fb4909b835472a36dd296d43a19d382b34eab15483efd610c2092493f | Python | 2,120 | 55 | from torch.utils.data import Dataset
class SingleImageDataset(Dataset):
# the purpose of this class is to contain a single image (and labels) and
# let us use a dataloader to get batches of slices. the optional parameter
# num_adjacent_slices controls how many adjacent slices to grab as inputs
def __i... |
6b6283f8d505138536b4d5a716518c911b6f06da661c46968fe1d7efc266a458 | Python | 2,121 | 58 | #!/usr/bin/env python
# Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma de
# Barcelona (UAB).
#
# This work is licensed under the terms of the MIT license.
# For a copy, see <https://opensource.org/licenses/MIT>.
import argparse
import os
import carla
def main():
argparser = argparse... |
0051e014153b1e451560040fb8a4841a7b74ef2e91025bb535d289858411bcc4 | Python | 2,122 | 56 | # Copyright 2020 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... |
193f9666430ed2ea4c1de6bb8deedca4c03d2d0a3ce81b1eac92c729940b3217 | Python | 2,122 | 53 | # Copyright 2021 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... |
16d8fecbd67917ca308fa75af5caa3ecb0db5132e39f66763ca8678ee728f819 | Python | 2,123 | 56 | # Copyright 2020-2022 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agre... |
26e58c3082df5caec2e63f2a0cbd79a6c0550402cfdbc4279fb8dcc0e193e5e2 | Python | 2,124 | 76 | import random
import torch
import numpy as np
import matplotlib.pyplot as plt
from graphxai.explainers import GNN_LRP
from graphxai.explainers.utils.visualizations import visualize_subgraph_explanation
from graphxai.gnn_models.node_classification import BA_Houses, GCN, train, test
from graphxai.gnn_models.node_classif... |
3d04957404cab0dd5402ce5d2d42cae25f1432a7c33dd9c7f8be7f2989f67082 | Python | 2,124 | 21 | from .base_options import BaseOptions
import sys
class TestOptions(BaseOptions):
def initialize(self, parser):
parser = BaseOptions.initialize(self, parser)
parser.add_argument('--shuffle', action='store_false', required=False, help='Shall the data be shuffled?')
parser.add_argument('--no_... |
c15fdccc6d96435813b32ce6eeda91a3ac16bb4b3a5bb1eff9425fe62c9e8ac3 | Python | 2,124 | 62 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Apr 29 15:32:08 2021
@author: tonifuc3m
"""
import pandas as pd
import warnings
from sklearn.metrics import f1_score, precision_score, recall_score
def warning_on_one_line(message, category, filename, lineno, file=None, line=None):
return '%s:%s: ... |
3a7979590cc3552cd57afbd83db03d3d15751a2f9d7bb78e1f7452dca711dc48 | Python | 2,125 | 58 | # Copyright 2021 Xiaomi Corporation (Author: Junbo Zhang)
# Apache 2.0
# This script compares the predicted output and the label and prints the result.
import sys
import argparse
import numpy as np
from sklearn import metrics
from utils import round_score, load_human_scores, load_phone_symbol_table
def get_args():... |
8ab65d9d76a61601bfc74aed891958803f18405b61f6f99ba27ee6d5b8585ed8 | Python | 2,125 | 56 | import os
from utils.SGCN.common import utils
from utils.SGCN.common.format import create_atom_label
def is_hydrogen(atom_name):
return ''.join([sym for sym in atom_name if not sym.isdigit()])[0] == 'H'
def check_atoms(df, allowed_atom_labels):
df_without_hydrogens = df[df.apply(lambda row: not is_hydrogen... |
b6f17a9c48b784ef3085f6e0e216782d4754915c9060a89bc2c0ad340b6239bf | Python | 2,125 | 55 | # Copyright (c) Open-MMLab. All rights reserved.
import torch
from torch.nn.parallel._functions import Scatter as OrigScatter
from ._functions import Scatter
from .data_container import DataContainer
def scatter(inputs, target_gpus, dim=0):
"""Scatter inputs to target gpus.
The only difference from original... |
0decb6011ff1962b270fde7da69a41412976ef38a90ed41881bab849e6d50b11 | Python | 2,127 | 54 | # -*- coding: utf-8 -*-
'''
@author: Mahbub Ul Alam (mahbub@dsv.su.se)
@version: 1.0+
@copyright: Copyright (c) Mahbub Ul Alam (mahbub@dsv.su.se)
@license : MIT License
'''
import torch.nn as nn
import torch
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
class RNN_LSTM(nn.Module):
def _... |
6793168f6452682434defc837cd118197bfd48947a0230200812d01ca2f665c7 | Python | 2,127 | 80 | """Plot group-average power maps and coherence networks for each mode.
"""
from sys import argv
if len(argv) != 3:
print("Please pass the number of modes and run id, e.g. python 6_plot_networks.py 6 1")
exit()
n_modes = int(argv[1])
run = int(argv[2])
#%% Import packages
import os
import numpy as np
from o... |
dc14822dd6fcf62c6e999843bd15cb784e048f41cc361c430686dc445e56d4c7 | Python | 2,127 | 77 | from graspy.inference import LatentDistributionTest
from os.path import basename
from pathlib import Path
import numpy as np
from sacred import Experiment
from sacred.observers import FileStorageObserver, SlackObserver
from graspy.models import SBMEstimator, DCSBMEstimator
from src.data import load_left, load_right
f... |
31c7d95412c00f10ef87693827c6081fa4035826be46e1fb09e5938234e27ff7 | Python | 2,128 | 73 | from __future__ import print_function
import os
import sys
import numpy as np
import torch
import random
from torch.autograd import Variable
from torch.nn.parameter import Parameter
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from tqdm import tqdm
import pdb
sys.path.append('%s/l... |
54501cfaf0a5534dbfd5d7fe6177bfd99601b7cf44d35d9c66462a45ba500349 | Python | 2,128 | 77 | from graspy.inference import LatentDistributionTest
from os.path import basename
from pathlib import Path
import numpy as np
from sacred import Experiment
from sacred.observers import FileStorageObserver, SlackObserver
from graspy.models import SBMEstimator, DCSBMEstimator
from src.data import load_left, load_right
f... |
ad3518688aa4c8b924ee17ea2b542931e06f7cb40a7fe86bdf265bf4de351f30 | Python | 2,128 | 77 | from graspy.inference import LatentDistributionTest
from os.path import basename
from pathlib import Path
import numpy as np
from sacred import Experiment
from sacred.observers import FileStorageObserver, SlackObserver
from graspy.models import SBMEstimator, DCSBMEstimator
from src.data import load_left, load_right
f... |
42099c483c6e6a2fa6fa6bf98184c88730b1b14dcd1b659dd8acbf6374b5e8eb | Python | 2,129 | 70 | from abc import ABC
from enum import Enum
from typing import Dict, List, Tuple, Iterable, Optional
# TODO: add funowl to dependencies
from funowl import Ontology, Axiom, Class, SubClassOf, EquivalentClasses
from oaklib.interfaces.basic_ontology_interface import BasicOntologyInterface
from oaklib.types import CURIE, LA... |
119e8147cd38bc41ea477770a6a8cd341ab8f136171a4785c124363368c04fbe | Python | 2,130 | 60 | """ Test utility functions """
import os
import sys
import numpy as np
import pytest
import torch
test_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.append(test_dir + '/../src')
import utils
@pytest.mark.parametrize('labels, true_correct',
[
([1, 0, 3],... |
5a4ee4ece6b8f423b38927b0bd4f91e96ea355cb1a851f360c1692f380a090e0 | Python | 2,130 | 59 | #!/usr/bin/env python3
"""
File: remove_covariate_effects.py
Created: 2020/10/19
Last Changed:
Author: M.Vochteloo
Copyright (C) 2020 M.Vochteloo
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Softw... |
191519b00af75ab7c09206823e4472ee27fee7056d12f2d51a39a81f21ade0f0 | Python | 2,131 | 68 | """
A safe space for different network setups.
Every setup creates one or more groups of cells.
The method "instantiate" will build the nest network and return a dictionary of the form: {group_id: [cell_id]}
The values are these groups of cell ids and the key, a group id.
They also have a constant attribute 'groups' t... |
ce27b118459c0dc550c12fb1042ce7d0b9b3951726463637d8830373ecbb2521 | Python | 2,131 | 58 | # Copyright 2022 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... |
d2cca01b44f1f5723e9d151c814fc02f2cd6906fb668dca4e687eb1474f4d1a3 | Python | 2,132 | 60 | import ipdb
import torch
import numpy as np
import matplotlib.pyplot as plt
import torch.nn.functional as F
from numpy import ndarray
from torch_geometric.utils import to_networkx
from graphxai.datasets.shape_graph import ShapeGGen
from graphxai.utils import to_networkx_conv, Explanation, distance
from tqdm import tran... |
82370f0e0575addcc588e352724f088162dabb3fc84c97b621a8301fea69452e | Python | 2,133 | 50 | # Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma de
# Barcelona (UAB).
#
# This work is licensed under the terms of the MIT license.
# For a copy, see <https://opensource.org/licenses/MIT>.
import carla
from . import SyncSmokeTest
TEST_TOWN = "Town10HD_Opt"
# Clearance on top of the two ... |
1cf9d20ca64f6e1fd65d83f79859b893aba58c9e4f12a661f9691be9a584c43d | Python | 2,134 | 63 | # generated by eelbrain/scripts/make_example_tests.py
import importlib.util
import logging
import os
from pathlib import Path
import re
from tempfile import TemporaryDirectory
import mne
import pytest
from eelbrain import configure
from eelbrain.testing import working_directory
DATASETS = {
'mne_sample': bool(m... |
851a33732958b1908903f2c3bdcd486554b977a9970a0eb7a2e872d00643572d | Python | 2,134 | 70 | """Step 5: Parcellation."""
from pathlib import Path
import matplotlib
matplotlib.use("Agg")
from osl_dynamics.meeg import parallel, parcellation, Session
# ----------------------------------------------------------------------------
input_dir = Path("BIDS")
output_dir = Path("derivatives")
qc_dir = Path("qc")
log_di... |
e75a8319a01070e21a5fa661d606bb999ef76f95e89e6c4052a239f119ccba69 | Python | 2,134 | 48 | __author__ = 'jieqing jiao'
__contact__ = 'jieqing.jiao@gmail.com'
import os
import nibabel as nib
import numpy as np
from niftypad.image_process.parametric_image import image_to_suvr_with_reference_tac
from niftypad.tac import Ref
# dt
dt = np.array([[
0, 5, 10, 15, 20, 25, 30, 40, 50, 60, 120, 180, 240, 300, ... |
3bb94f1c2c531ff0cb39fa20daff31d4c461e2f229c50a6f5ed9556c99028255 | Python | 2,135 | 50 | # Copyright 2022 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... |
afb21e6010f78e5032259fdeedc78e45f8f73929b785372739dbe3831a05762d | Python | 2,135 | 77 | from graspy.inference import LatentDistributionTest
from os.path import basename
from pathlib import Path
import numpy as np
from sacred import Experiment
from sacred.observers import FileStorageObserver, SlackObserver
from graspy.models import SBMEstimator, DCSBMEstimator
from src.data import load_left, load_right
f... |
c596757f060fc50c3abc807bd162013fe9ea85cb0f1339d6e7d87a984bf5ac50 | Python | 2,135 | 47 | import os, sys; sys.path.append('..')
import numpy as np
from torch_geometric.datasets import TUDataset
from graphxai.explainers import IntegratedGradExplainer
#from graphxai.explainers.utils.visualizations import visualize_mol_explanation
from graphxai.gnn_models.graph_classification import train, test
from graphxai.... |
f0426d5dad306124568dd6753aa1330ea50d3ae3525040140928df90350755c8 | Python | 2,136 | 77 | from graspy.inference import LatentDistributionTest
from os.path import basename
from pathlib import Path
import numpy as np
from sacred import Experiment
from sacred.observers import FileStorageObserver, SlackObserver
from graspy.models import SBMEstimator, DCSBMEstimator
from src.data import load_left, load_right
f... |
3d870cd7bba1b8784fb08ddca4f1932f963f96f34b6ee689758391aef4ce394d | Python | 2,137 | 77 | from graspy.inference import LatentDistributionTest
from os.path import basename
from pathlib import Path
import numpy as np
from sacred import Experiment
from sacred.observers import FileStorageObserver, SlackObserver
from graspy.models import SBMEstimator, DCSBMEstimator
from src.data import load_left, load_right
f... |
506402dacfa4ba39b275d01771e4857c4be3822a4cec46a13b4363876c8e7593 | Python | 2,137 | 72 | import numpy as np
from numpy.matlib import repmat
"""
compute_normal.py: Compute the normals of a closed shape.
Pablo Gainza - LPDI STI EPFL 2019
This file is part of MaSIF, based on previous matlab code by Gabriel Peyre, converted to Python by Pablo Gainza
"""
###
from default_config.global_vars import epsilon as ep... |
bb17795f9c0159c6d4587a32da3c78e27efa35de933494296600297729940a07 | Python | 2,137 | 54 | """
© 2022, ETH Zurich
"""
import os
import joblib
import pandas as pd
from rescoss_logp_ml.data_handling.data_handling import load_dataset
from rescoss_logp_ml.utils import SEED, get_output_dir
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_absolute_error, mean_squared_error
from... |
7bfe6e0f4ade1fbd5449fe095dde01b9f002bcff9a430a144fa0b72859f048ee | Python | 2,139 | 63 | import numpy as np
import mpmath as mp
from ..forward import network_transfer_laplace
def ntf_macro_inverselaplace(brain,parameters,tt,noisein):
C = brain.reducedConnectome
D = brain.distance_matrix
tau_e = parameters["tau_e"]
tau_i = parameters["tau_i"]
speed = parameters["speed"]
gei = param... |
a6c388050827246d6b535f39d549bb23c46bc90267046aa0639f27e326dbd39a | Python | 2,139 | 69 | ## 2018/12/02
# Gene Regulatory Network Simulation Using Simple Multivariate Gaussian
# Take input through argparse
## Plots
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
from matplotlib import offsetbox
from matplotlib import cm
import seabor... |
db5935cb66a8d0dca307a5a18fdd267af165686418ce335358b74a2c1fc13340 | Python | 2,139 | 59 | import csv
import sys
from dataclasses import dataclass, field
from typing import Any, Dict, Union, Tuple
from linkml_runtime import CurieNamespace
from linkml_runtime.utils.enumerations import EnumDefinitionImpl
from linkml_runtime.utils.yamlutils import YAMLRoot
from oaklib.interfaces.obograph_interface import OboGr... |
052bd55b2b8672714166946891827840b659fd85cc44e53e0feb72d1b1f7696c | Python | 2,140 | 71 | import fnmatch
def heur(physinfo, take=""):
"""
Set of if .. elif statements to fill BIDS names.
It requires the user (you!) to adjust it accordingly!
It needs an ``if`` or ``elif`` statement for each file that
needs to be processed.
The statement will test if the ``physinfo``:
- is s... |
040de211e4708dd8b93609b88c61fdaf97ab50109d4e84a9a8fb7aecb4d23582 | Python | 2,141 | 71 | import fnmatch
def heur(physinfo, take=""):
"""
Set of if .. elif statements to fill BIDS names.
It requires the user (you!) to adjust it accordingly!
It needs an ``if`` or ``elif`` statement for each file that
needs to be processed.
The statement will test if the ``physinfo``:
- is s... |
3b52a81a04128e2daccf3742bf4e35229c922f6a3a4eae27a725c8a2435ec3f4 | Python | 2,141 | 61 | # Copyright 2022 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... |
86123808aac30568707041b7e68a2be00720cb09e596fccbe1c2079b22d28a1b | Python | 2,141 | 59 | # Copyright 2021 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... |
13a3412d765f7e5c8b179e17647885593db927bcdf25d9a32970483542fbd9a7 | Python | 2,142 | 54 | from tensorlayer.layers import *
from tensorlayer.third_party.roi_pooling.roi_pooling.roi_pooling_ops import \
roi_pooling
# from roi_pooling.roi_pooling_ops import roi_pooling
# input feature map going into the RoI pooling
input_value = [[[[1], [2], [4], [4]], [[3], [4], [1], [2]], [[6], [2], [1], [7.0]], [[1], ... |
dd2dc7f754980e603c57a7163bdf36a9a21ecd93fc5b6b9a15ddf8bbaac957f2 | Python | 2,143 | 71 | import fnmatch
def heur(physinfo, take=""):
"""
Set of if .. elif statements to fill BIDS names.
It requires the user (you!) to adjust it accordingly!
It needs an ``if`` or ``elif`` statement for each file that
needs to be processed.
The statement will test if the ``physinfo``:
- is s... |
61391e3048f3a5e7fc636810b5f316ef638acc6fa98ad826e23e82d0c88e2f07 | Python | 2,144 | 57 | import random
import torch
import matplotlib.pyplot as plt
from graphxai.explainers import GuidedBP
from graphxai.explainers.utils.visualizations import visualize_subgraph_explanation
from graphxai.gnn_models.node_classification import BA_Houses, train, test
from graphxai.gnn_models.node_classification.testing import ... |
639f069c0dfc7be14751e640ac39ed83d288365865086139d021c7c1b0130c14 | Python | 2,145 | 53 | import logging
from collections import Iterable
class ArchGenerate_FNA(object):
def __init__(self, super_network):
self.primitives_normal = super_network.primitives_normal
self.primitives_reduce = super_network.primitives_reduce
if hasattr(super_network, 'primitives_for_head'):
... |
da47ed1fa05ce1474f8140ea6426595f9f0551816fb02d7d1d6d0ee67dc5265d | Python | 2,146 | 70 | '''
GUI for Paramecium movie processing
'''
import matplotlib.pyplot as plt
from matplotlib.widgets import Button, Slider, TextBox
import numpy as np
__all__ = ['image_gui']
def image_gui(parameters={}, callback=None, on_click=None):
'''
Produces a GUI that displays an array and parameter boxes.
Changing ... |
08a8db0354c49e8f1e3e335ffe584ddf9108db5276622fa9d4e42231b0b8b9b8 | Python | 2,147 | 53 |
# loop through all subdirs to find all fastq files
import os.path
import argparse
parser = argparse.ArgumentParser(description='Make Molgenis Compute samplesheet for CMC_HBCC.')
parser.add_argument('samplesheet', help='CMC samplesheet from synapse')
parser.add_argument('cram_dir', help='path to cram file dir for inp... |
8a92dc2fae1ac278d2219435634acf4c6fcc5b47cf81a1429b7d2a2f1db275ae | Python | 2,147 | 53 | import os
import sys
import json
import datetime
import pandas as pd
def cross_reference(day):
infofile = "setup_information.json"
f = open(infofile)
info = json.load(f)
dtx_file = os.path.join(info['archive_path'], day.strftime('%Y-%m-%d'), day.strftime('%Y-%m-%d') + '_daily_tx_list.xlsx')
dct_fi... |
d52279d0a6fca0f006a5d6087bbde11059e70af30619d2927f4a8dfe18935b5e | Python | 2,147 | 77 | """
Title
-----
LIF network + inhibition
Description
-----------
In this example, we present a simple network of generic leaky integrate-and-fire
units comprising interconnected excitatory and inhibitory neurons.
In this example, we also explore:
- How to add different types of synaptic equations.
- How to achieve m... |
38a2c9fd38293281df6bf1d3305b95faa6d474985a42e997754189beb5742215 | Python | 2,148 | 67 | # Copyright (c) Open-MMLab. All rights reserved.
from abc import ABCMeta, abstractmethod
from ..hook import Hook
class LoggerHook(Hook):
"""Base class for logger hooks.
Args:
interval (int): Logging interval (every k iterations).
ignore_last (bool): Ignore the log of last iterations in each ... |
9e97afba76cf633aec0d5401cf3131ddc75d1e7fb7dafb60d799b9fee8003ecb | Python | 2,150 | 44 | # Copyright 2021 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... |
91fd599bb3c23d88faaa2b02425437b99d75e07de1ea59b4e35549d38c3a1388 | Python | 2,151 | 68 | import os
from mne.io import read_raw, read_raw_egi
def get_file_selection_options(file_paths: dict, allowed_extensions=[]):
"""Generates list with file-selection options for dcc.Dropdown.
Args:
file_paths (dict): Dictionary with keys pointing to directories whose files are included in options.
... |
9c7d9d74483f1c07bed10a3e5ecb0a1e46d9222c52440a9936630252a2655593 | Python | 2,151 | 60 | import sys
from mmdet.core import merge_aug_proposals
if sys.version_info >= (3, 7):
from mmdet.utils.contextmanagers import completed
class RPNTestMixin(object):
"""Test methods of RPN."""
if sys.version_info >= (3, 7):
async def async_simple_test_rpn(self, x, img_metas):
sleep_in... |
061f7958aaf94120e8838c83f0c94d80940b13593124961aa22510ff70756b16 | Python | 2,154 | 69 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch import nn
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from torch.nn.modules.utils import _pair
from maskrcnn_benchmark import _C
from apex import amp
class _ROIAlign(Functio... |
36e3a5ceece1b998bf2f37428098b1b3225a640717df619d23bb3acd2b980ac9 | Python | 2,154 | 71 | '''
Created by: Zhiqing Guo
Institutions: Hunan University
Email: guozhiqing@hnu.edu.cn
Copyright (c) 2020
'''
import torch
import torch.nn as nn
import network.resnet_mta as resnet_mta
import network.resnet_plain as resnet_plain
import torch.nn.functional as F
# Load model
plain_stream = resnet_plain.resnet18_plain(p... |
94140198e2c63d7086aa9a1f69f9f64a60d7467d6c9fd48d177b11050ce97aff | Python | 2,157 | 62 | import os
import cv2
import numpy as np
import glob
import os.path as osp
from insightface.model_zoo import model_zoo
class LandmarkModel():
def __init__(self, name, root='./checkpoints'):
self.models = {}
root = os.path.expanduser(root)
onnx_files = glob.glob(osp.join(root, name, '*.onnx'... |
366ade03b3eccd59821643bb421061ea0ace6f9c08ae17fcdca279759173dc7a | Python | 2,160 | 67 | # Copyright 2020-21 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed... |
89ea6fd4fb073b492f6c16d677ea13f8adce6746890f5cf4dd2b154b260e1ba6 | Python | 2,160 | 57 | import ipdb
import random
import torch
import argparse
from graphxai.gnn_models.node_classification.testing import GCN_3layer_basic, GIN_3layer_basic, test, train, val
from graphxai.gnn_models.node_classification.testing import GIN_1layer, GIN_2layer
from graphxai.datasets.shape_graph import ShapeGGen
from graphxai.dat... |
998f58b7669045a7be0da29da539a954ef0f114ade41fc1926f5e49f11538759 | Python | 2,160 | 68 | #!/usr/bin/env python
from __future__ import print_function
import sys
import argparse
import logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
handler = logging.StreamHandler()
handler.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s [%(filename)s:%(lineno)s - %(funcName)s -... |
14a1c91f783854cc2c6f50488f92b00cf3050f5ffbf92de5b54385c597fd1c49 | Python | 2,162 | 52 | #!/usr/bin/env python
# Copyright Johns Hopkins University (Author: Vijayaditya Peddinti) 2015. Apache 2.0.
# This script checks the ctm for missing recordings and places a dummy id.
# This is necessary for compliance with sclite scoring scripts
import argparse, sys
def fill_ctm(input_ctm_file, output_ctm_file, rec... |
1d877e6ef8e7a3db143c9cfb78950752c539cb3bb641bdb1eaf0e9a7ed351602 | Python | 2,162 | 59 | # Copyright 2020-2021 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agre... |
30af29ff67b62916ff857ce376e42fbba8e056e5ca7cad8e1b8cb40484363582 | Python | 2,162 | 67 | """Tests for the VLAAI network."""
import os
import unittest
import numpy as np
import tensorflow as tf
from scipy.stats import pearsonr
from model import vlaai, pearson_loss, pearson_metric
class VLAAITest(unittest.TestCase):
"""Tests for the pre-trained VLAAI models."""
def setUp(self) -> None: # noqa:... |
423ef203a2c9c7c389456ac8ddb627ba4f8029d615d1999d7eff24bb59254761 | Python | 2,163 | 108 | #%%
import time
from src.data import load_maggot_graph, load_palette
from src.io import savefig
from src.visualization import set_theme, ORDER_KEY, HUE_KEY
print("ORDER_KEY = ", ORDER_KEY)
print("HUE_KEY = ", HUE_KEY)
t0 = time.time()
set_theme()
def stashfig(name, **kws):
savefig(
name,
pathna... |
98cb1460cab3456b9f44ebbb6f077dce8cd6b716355ceeab70632a5705117330 | Python | 2,164 | 50 | import torch.nn as nn
from models.baselines.base_model import mobilenet1_0, mobilenet_v2_1_0, mobilenet_v3_small_1_0, mobilenet_v3_large_1_0, igcv3_1_0, efficientnet_b0
class BaseModel(nn.Module):
def __init__(self, nclass, aux=False, backbone='mobilenet', pretrained_base=False, **kwargs):
super(BaseMode... |
eeec15c8a2e1245f92ed480936198569c4adadf8eaeee09185c1e42c7ab77fbd | Python | 2,164 | 56 | """Novel-odor probing task.
Protocol:
1. Train both models on CS+/CS- conditioning until they converge.
2. Probe phase (no learning):
a. Familiar probe — re-present CS+ and CS- without reward, multiple repeats.
b. Novel probe — present N never-seen-before PN patterns once each.
c. Mix... |
8ecb18992d0f7e8a1884f16055cdef44729a890e97f0b7803f22f63ae8555df9 | Python | 2,166 | 61 | '''
Ohmic IK model with bell-type time constant, for fitting depolarized responses in deciliated cells.
p = 2 and baseline time constant nearly 0.
Time constant peaks at V_IK, with slope twice the activation slope.
'''
from file_management import *
from brian2 import *
from brian2modelfitting import MSEMetric
from fitt... |
cef033b38cfcc44f562d6a527693f83281a0cd172f61c68175e5725cb6bdac16 | Python | 2,167 | 58 | import numpy as np
import h5py
import multi_slice_viewer as msv
import scipy.ndimage as ndimage
import matplotlib.pyplot as plt
import SimpleITK as sitk
from scipy.ndimage import zoom
from h5functions import save_to_h5
def load_mhd(filename):
'''
https://stackoverflow.com/questions/37290631/reading-mhd-raw... |
a001a28d362e7201cf9f54ca0facfa20a9f502a71f5af1ba14ee68fd0531ee90 | Python | 2,169 | 68 | """
Permutation tests on individual ferret data to determine the effect of cooling
on performance discriminating vowels for each noise condition (clean / noise)
Version History
----------------
2021-11-01: Branched from vin_cooling_by_ferret.py
"""
import os, sys
from pathlib import Path
import pandas as pd
sy... |
5001e30db19539eac090b8e37381ad6101d8f389ef9b9ca617792f7da9a5a508 | Python | 2,171 | 62 | '''
Ohmic IK model with HH-type equations, for fitting depolarized responses in deciliated cells.
p = 2 and baseline time constant nearly 0.
'''
from file_management import *
from brian2 import *
from brian2modelfitting import MSEMetric
from fitting import *
from plotting import plot_fits
from brian2.units.constants im... |
1b4740174f332d08d8f101b8dbc620e7d22b17457c11a8e6c85e048da4fa4558 | Python | 2,174 | 62 | '''
Ohmic IK model with bell-type time constant, for fitting depolarized responses in deciliated cells.
p = 2 and baseline time constant nearly 0.
'''
from file_management import *
from brian2 import *
from brian2modelfitting import MSEMetric
from fitting import *
from plotting import plot_fits
from brian2.units.consta... |
314561ad13f5dbb3f5fa7e4da843d168ec8f12eec174d07a72ba09a6dd09a923 | Python | 2,174 | 64 | # Copyright 2021 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... |
8d49f61e5d535615a0fd253ad2c4fd6750cde6f7f4e125dfe50e779e3ddde6b6 | Python | 2,174 | 62 | import os
import sys
import numpy as np
import n5_metadata_utils as n5mu
import pandas as pd
from glob import glob
from skimage.io import imread
from os.path import abspath, dirname
if __name__ == '__main__':
lb_dir = sys.argv[1]
spot_glob_pattern = sys.argv[2]
out_dir = sy... |
180e83d644f586f59ad729b52095f416dd1c6a93bf7f2713f04d61a4d7690e24 | Python | 2,175 | 72 | import copy
from operator import mod
import matplotlib.pyplot as plt
from sklearn.metrics import accuracy_score
import torch
from tqdm import tqdm
from train import train
from model import Unquantified_2layer_CNN, VGGMini_CNN
from utils.function import direct_quantize
from utils.dataTrans import get_dataloade... |
2809bdc54d9fa484954f91c1a1cb2a48d29d4689e66e771b2a7dfc4618fa52ae | Python | 2,176 | 72 | # Copyright 2021 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... |
55d69db1d607bc914d0d74d189832f70ac28fc5e814043b5250e2179dc90f3b3 | Python | 2,176 | 86 | """
"""
from preset import *
n_stim = 3
stim_pars = dict(
n_stim=n_stim,
elements= np.arange(0, n_stim, 1),
grammar= None,
full_set_length=int(11),
transient_set_length=int(1),
train_set_length=int(8),
test_set_length=int(2))
# Input Parameters
inp_resolution = .1
inp_amplitude = 1500.
... |
c12636caa08e227719915adaba3474c8bca6a9b59ae1c62e53e89e73b45c0d1a | Python | 2,176 | 43 | # Copyright 2021 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... |
d532e1a3aebb41d967e6b8abcf0da24013dbfc623095b6822fe42736a08f399a | Python | 2,176 | 64 | ###
# #%L
# Triangulated surface for deforming in 3D.
# %%
# Copyright (C) 2013 - 2023 University College London
# %%
# 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, incl... |
0d23ac4a735b57e53d1868c5e226540e5304128e4137ff30d8d86ed759232f5c | Python | 2,177 | 29 | """Town road network from the Map API: lanes, junctions, spawn points with indices."""
import sys, carla, numpy as np
import matplotlib; matplotlib.use("Agg"); import matplotlib.pyplot as plt
out = sys.argv[1]
c = carla.Client("localhost", 2000); c.set_timeout(60); m = c.get_world().get_map()
wps = m.generate_waypoints... |
d6ab31c753473ff0a842d15b6e04c77833a28773ee907aa51a46223b8ef74542 | Python | 2,177 | 70 | """
From https://github.com/wanghao14/Stain_Normalization
Stain normalization inspired by method of:
A. Vahadane et al., ‘Structure-Preserving Color Normalization and Sparse Stain Separation for Histological Images’, IEEE Transactions on Medical Imaging, vol. 35, no. 8, pp. 1962–1971, Aug. 2016.
Uses the spams packag... |
e06bb9a561b3a97b50b682f6fb80e57f6cd1341caeb6e60b329149ce9108035a | Python | 2,177 | 85 | # Copyright 2020 Google Research. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... |
03334d17974a28b07075e68b3807f1990d6e209711cce2220a1756e0629f28f0 | Python | 2,178 | 76 | import os
from tqdm import tqdm
from skimage.transform import resize # not using, highly inefficient
import nibabel as nib
import numpy as np
from torch.utils.data import Dataset
class BratsDatasetEval(Dataset):
def __init__(
self,
args,
data,
):
self.data = data
self.... |
ac19e02efbac65ed0c481d2bd71b4d99c5a36a87660e8e66cd558f39ef4587f2 | Python | 2,178 | 60 | #!/usr/bin/env python3
#
# Copyright (c) 2017 Institute for Basic Science
#
# 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 u... |
d786203ef6aaeb0b4b8b47fe8e8ed4dd5d157ccee738791cbdf860fc9776dc88 | Python | 2,178 | 61 | #!/usr/bin/env python
# Copyright 2016 Allen Guo
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# THIS CODE IS PROVIDED *AS IS* BASIS, WITH... |
7ffecba95286b8223e57cc96e941469c850b4906a2cad9510b8e5c3662fdfbaa | Python | 2,179 | 67 | # -*- coding: utf-8 -*-
from .core import *
from .. import _logging as logging
import tensorflow as tf
__all__ = [
'PReluLayer',
]
class PReluLayer(Layer):
"""
The :class:`PReluLayer` class is Parametric Rectified Linear layer.
Parameters
----------
layer : :class:`Layer`
Previous l... |
800ac65e8fab9742c5a7d0483f0cd2590922420c215530dc7db1c79846db75ea | Python | 2,179 | 76 | """
Title
-----
Dendritic attenuation
Description
-----------
The attenuation of currents traveling along the somatodendritic axis is an
intrinsic property of biological neurons and is due to the morphology and cable
properties of their dendritic trees. (also see `Tran-van-Minh et al, 2015
<https://www.frontiersin.or... |
9a7838194dfde7f1c559e89ce52cb33f1b8a4abed024d67a926880dd0764203c | Python | 2,180 | 73 | # Copyright 2021 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... |
b00ade027a0121a8cd5de6a784e75d290de97708b7f5c0aca938532ae0acafa1 | Python | 2,180 | 69 | """
Tests phys2bids.py
"""
import os
import json
from phys2bids import phys2bids
from pkg_resources import resource_filename
def test_print_summary(tmpdir):
test_filename = 'input.txt'
test_ntp_expected = 10
test_ntp_found = 5
test_samp_freq = 0.2
test_time_offset = 0.8
test_outfile = tmpdir.... |
86e49d0ade626d109271dd2a807b49b02ea0b8e7c30f44b54deb474c0dfce97e | Python | 2,181 | 85 | import sys
import re
# check parameters
if (len(sys.argv) < 3):
print("Usage: result.obj to_add.obj [material_id]")
sys.exit(1)
#----------------------------------
# read total of vertex already used
#----------------------------------
totalVertex = 0
try:
f = open(sys.argv[1], "rt")
lines = f.readlines()
for li... |
e7e83106ae32dbced6e22db67e7ecb57c31c4c992d8b0adb73054916eed33f93 | Python | 2,181 | 67 | from functools import partial
import mmcv
import numpy as np
import torch
from six.moves import map, zip
def tensor2imgs(tensor, mean=(0, 0, 0), std=(1, 1, 1), to_rgb=True):
"""Convert tensor to images.
Args:
tensor (torch.Tensor): Tensor that contains multiple images
mean (tuple[float], opt... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.