sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
c3a7e5bc4089fea387540bf8f119795bda5a998889b0ead62a75e506f94b8798
Python
3,652
88
""" Author: Mingjian He <mh1@stanford.edu> Testing functions for the dOsc algorithm in somata/oscillator_search/decomp_osc.py """ from somata.oscillator_search import DecomposedOscillatorModel as DecOsc from somata import OscillatorModel as Osc from test_load_data import _load_data # type: ignore import numpy as np ...
e4ffd0f3053b6a605e54060193d6cff4ad89f5abc5119308524dbb9624818d84
Python
3,652
111
# TODO Sep 08 version from __future__ import print_function import os import tarfile import requests from warnings import warn from zipfile import ZipFile from bs4 import BeautifulSoup from os.path import abspath, isdir, join, basename class GetData(object): """A Python script for downloading CycleGAN or pix2pix ...
a5602c8effc5122a27ce89fae54c2513ebf5244331d7a1e766cc07d895b7a70e
Python
3,654
116
""" pysteps.feature.blob ==================== Blob detection methods. .. autosummary:: :toctree: ../generated/ detection """ import numpy as np from pysteps.exceptions import MissingOptionalDependency from scipy.ndimage import gaussian_laplace try: from skimage import feature SKIMAGE_IMPORTED = ...
89836cf3c2243655bc3d571e752c98d1ac2a80393617df3dab5c04794d82cb98
Python
3,656
121
# -*- coding: utf-8 -*- """ pysteps.visualization.tstorm ============================ Methods for plotting thunderstorm cells. Created on Wed Nov 4 11:09:44 2020 @author: mfeldman .. autosummary:: :toctree: ../generated/ plot_track plot_cart_contour """ import matplotlib.pyplot as plt import numpy as...
7d3f602c23984da9444a7195949a2d35b11ff034ba8789f333f2d61e907a481e
Python
3,658
87
builtin_modules = { "calculatemath": "CalculateMath", "calculatestatistics": "CalculateStatistics", "classifyobjects": "ClassifyObjects", "closing": "Closing", "colortogray": "ColorToGray", "combineobjects": "CombineObjects", "convertimagetoobjects": "ConvertImageToObjects", "convertobje...
83ee0cf3628b44f0ce01a60cab9ec4a1c0ffe830162d482256be73af6f163b7a
Python
3,661
95
from tempfile import mkdtemp from shutil import rmtree import os import numpy import h5py from nose.tools import eq_, ok_ from deeprank.domain.amino_acid import amino_acids from deeprank.models.variant import PdbVariantSelection, VariantClass from deeprank.operate import hdf5data def test_group_name(): variant1...
4d9329623ccf5c3f24a0e741ee4a242584ad41c7cccd00f4cff372b31beec70a
Python
3,662
124
#!usr/bin/env python # -*- coding: utf-8 -*- import argparse import os import yaml from typing import Optional import click from deprecated.classic import deprecated from GANDLF.cli import copyrightMessage, split_data_and_save_csvs from GANDLF.entrypoints import append_copyright_to_help from GANDLF.utils import logg...
b1120cfd82bcaecfaddea7ebff7d2cad880eafe4f9d864428137b300872c2272
Python
3,663
126
import torch import torch.nn as nn import torch.nn.functional as F class InceptionModule(nn.Module): def __init__( self, input_channels, output_channels, Conv, Dropout, InstanceNorm, dropout_p=0.3, leakiness=1e-2, conv_bias=True, inst...
083cb72fad9c53393fd6e789a750bfb4977bf37a936db9eac121b2d2789ba019
Python
3,664
106
import csv import math import sys import os # This program takes in aa acid frequencies at each position from raw CNN output. ''' 1) Calculate the entropy and n-eff for each position 2) Save to csv file ''' def get_entropy(freq_list): sum = 0 for freq in freq_list: freq = float(freq) sum += freq * (1 if...
a9a8047d7627d907e3f76226cf27f3b645a02d7580988066202cd4ed227d1560
Python
3,666
98
from ._setting import Setting from ._validation_error import ValidationError class Joiner(Setting): """The joiner setting defines a joining condition between conceptual tables You might want to join several tables by specifying the columns that match each other or might want to join images in an image se...
08dde908b8f4089c208ac17d5411b6763c7f1aa6e945f1ab45d22469be7ad9a3
Python
3,671
129
import logging import pickle from ._setting import Setting from ._validation_error import ValidationError LOGGER = logging.getLogger(__name__) class ImagePlane(Setting): """A setting that specifies an image plane This setting lets the user pick an image plane. This might be an image file, a URL, or a p...
03060eba161e213afa10598489002d3da6bc584b4f8cd1ba48a0f1cfc2e265bd
Python
3,672
79
"""Validate descriptive processing history without applying transformations.""" from __future__ import annotations import re from collections.abc import Mapping from typing import Any from datamonger._errors import UnsupportedRegistryError from datamonger._validate import require_array, require_mapping, require_stri...
c5c9dab02495e9e2f93e105c2418f8c7ac6bc5551509c03c1ac8446adea38887
Python
3,681
87
import sys from argparse import ArgumentParser import logging import pytorch_lightning import torch workspace_path = '/mnt/netcache/bodyct/experiments/airway_labeling_t7828/bronchial' print("We add {} into python path for module lookup.".format(workspace_path)) sys.path.append(workspace_path) from pytorch_lightning.s...
5d49f11c153a12d74d3d89a6dfcf4059c23f9c23f2ddaaf2322314acd4fda95a
Python
3,682
93
# -*- coding: utf-8 -*- # (C) Copyright 2020, 2021, 2022, 2023 IBM. All Rights Reserved. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any...
7a35d42212cd8d1cd379b17eeee098525b8aee3c883433a92dedb284e29a7098
Python
3,683
106
from typing import Tuple import torch import torchio def handle_nonempty_batch(subject: dict, params: dict) -> Tuple[dict, int]: """ Function to detect batch size from the subject an Opacus loader provides in the case of a non-empty batch, and make any changes to the subject dictionary that are needed for GaN...
7177ed4e7f9efd7afa17c555e6594aae831f2d8284d65d46ee2f3d36541e4280
Python
3,684
122
import numpy as np from torchio.transforms import ( OneOf, RandomMotion, RandomGhosting, RandomSpike, RandomAffine, RandomElasticDeformation, RandomBiasField, RandomSwap, RandomNoise, RandomAnisotropy, RandomFlip, RandomGamma, ) from .blur_enhanced import RandomBlurEnhan...
26e65b72c83d1984e72cee2549fb70aee6a4cbe44a744dfd76b8eecd2627b077
Python
3,685
98
""" ClinicalASL - Clinical Arterial Spin Labeling processing pipeline ASL T1-from-M0 computation module. Repository: https://github.com/JSIERO/ClinicalASL Author: Jeroen Siero Institution: UMCU (University Medical Center Utrecht), The Netherlands Contact: j.c.w.siero@umcutrecht.nl Description: Functions for bra...
45d05ee0db2ca5ce53120ea9119a4dbcff0b6c87c44943afae41a6ba9c04b158
Python
3,685
143
from __future__ import division from numpy import * from matplotlib.mlab import * from circ_stats import * from scipy.stats import * from scikits.bootstrap import ci from scikits import bootstrap from scikits.bootstrap import bootstrap_indexes import statsmodels.nonparametric.smoothers_lowess as loess from constants i...
ab97ed1fbe17137e7e2fe1f934066cb5d2180bc9682ebf4ae991a76abfd0150c
Python
3,687
109
import pytest from click.testing import CliRunner from GANDLF.entrypoints.optimize_model import new_way, old_way from . import CliCase, run_test_case, TmpDire, TmpFile, TmpNoEx # This function is a place where a real logic is executed. # For tests, we replace it with mock up, and check if this function is call...
fb71f37b4b616848298c1e656c61edb126cb62371b523b0768c5b237dbcb4c02
Python
3,688
112
""" Split Attention Conv2d (for ResNeSt Models) Paper: `ResNeSt: Split-Attention Networks` - /https://arxiv.org/abs/2004.08955 Adapted from original PyTorch impl at https://github.com/zhanghang1989/ResNeSt Modified for torchscript compat, performance, and consistency with timm by Ross Wightman """ from typing import...
94a9961903532188f6ff5df300a7958a18c8186f8a1f0dda6a0ee36afd0fd2a3
Python
3,689
117
""" pysteps.nowcasts.extrapolation ============================== Implementation of extrapolation-based nowcasting methods. .. autosummary:: :toctree: ../generated/ forecast """ import time import numpy as np from pysteps import extrapolation def forecast( precip, velocity, timesteps, ext...
fc5c40c06fe54845111cc76779b39f4236a288b485d925004500085c34799e64
Python
3,692
68
from torch.utils.data.sampler import Sampler import numpy as np from sklearn.utils.class_weight import compute_class_weight import time import logging class SubtypingStratifiedSampler(Sampler): def __init__(self, data_source, balance_label_count): super(SubtypingStratifiedSampler, self).__init__(data_sourc...
66b47f054fbf4a9f8fa9d19f3edab322c2e3828f783e00471f004641ff300568
Python
3,700
140
# -*- coding: utf-8 -*- """ pysteps.utils.fft ================= Interface module for different FFT methods. .. autosummary:: :toctree: ../generated/ get_numpy get_scipy get_pyfftw """ from pysteps.exceptions import MissingOptionalDependency from types import SimpleNamespace def get_numpy(shape, ff...
7de1d485bcc286697774d126835706c15b81635a6ac4a796c312286ebf734033
Python
3,705
139
# -*- coding: utf-8 -*- import pytest import numpy as np from pysteps import downscaling from pysteps.tests.helpers import get_precipitation_fields from pysteps.utils import aggregate_fields_space, square_domain, aggregate_fields @pytest.fixture(scope="module") def data(): precip, metadata = get_precipitation_fi...
ddec986d024c3dc819cfa343645a4969d6e051d9cc17a721b9d44aaa605a2781
Python
3,712
112
#!usr/bin/env python # -*- coding: utf-8 -*- import argparse from typing import Optional import click from deprecated import deprecated from GANDLF.cli import copyrightMessage, recover_config from GANDLF.entrypoints import append_copyright_to_help from GANDLF.utils import logger_setup def _recover_config(model_dir...
22c4c295a3987e0a190ab1b59d2e9135ef5ce8380fc06e806731aa303c1f937e
Python
3,717
115
import numpy as np import os.path as osp import scipy import matplotlib.pyplot as plt import seaborn as sns import sys sys.path.append('..') from numpy.random import seed from sklearn.metrics import jaccard_score from functions.def_ROIs_EarlyVisualAreas import roi as ROI from functions.def_ROIs_DorsalEarlyVisualCorte...
22cfa9ae32b33854f906ad10d52e209fa8b8564876f7b8f789a8aafff1e66c84
Python
3,717
109
import pytest from click.testing import CliRunner from GANDLF.entrypoints.recover_config import new_way, old_way from . import CliCase, run_test_case, TmpDire, TmpFile, TmpNoEx # This function is a place where a real logic is executed. # For tests, we replace it with mock up, and check if this function is call...
951bd10cac8fa84b3e092f4ba602a39a111ae28c34e7a6ef7798f9e38f972912
Python
3,718
82
import numpy as np import meshes as ms import matplotlib.pyplot as plt from scipy.stats import unitary_group from numba import njit class EOIntensityModulation: def __init__(self, alpha=0.1, g=np.pi, phi_b=np.pi): self.alpha = alpha; self.g = g; self.phi_b = phi_b def __call__(self, inputs): (a...
f929717d915fe22ebc7b61e71dc97c99abe28edce6673585ee0e02c25a0cd8eb
Python
3,718
109
from __future__ import annotations import numpy as np from scipy.signal import resample import traits.api from ptsa.data.timeseries import TimeSeries from ptsa.data.filters import BaseFilter class ResampleFilter(BaseFilter): """Resample a time series to a new sample rate. Parameters ---------- resa...
3239457aad443f885b74633d561c28b6733b0a1675b35d72d28285cab79b81a9
Python
3,719
88
from functools import partial from typing import Any, Optional import torch import torch.nn as nn import torch.nn.init as init class Fire(nn.Module): def __init__(self, inplanes: int, squeeze_planes: int, expand1x1_planes: int, expand3x3_planes: int) -> None: super().__init__() self.inplanes = in...
4a09ce6bc34f76fb8eff63a192e78b06744a05bcc1a44af73d8af4aa396f1bdc
Python
3,729
142
from __future__ import annotations import sys from typing import Dict, Optional from imctools.data.slide import Slide if sys.version_info >= (3, 8): from typing import TypedDict # pylint: disable=no-name-in-module else: from typing_extensions import TypedDict class PanoramaDict(TypedDict): slide_id: i...
890c605cb811391d72a512e9b9e06c758aba79107f9fa603c6e5703be8fb31a8
Python
3,729
219
class TestModule: def test_create_settings(self): pass def test_create_from_handles(self): pass def test_prepare_settings(self): pass def test_set_settings_from_values(self): pass def test_upgrade_settings(self): pass def test_post_pipeline_load(self)...
9f9da1fac6b33ca0c50f6f2abfbfab836680ed7620b808ffc8d5bf0ca93bcbc7
Python
3,732
114
# -*- coding: utf-8 -*- import numpy as np import pytest from pysteps.tracking.tdating import dating from pysteps.utils import to_reflectivity from pysteps.tests.helpers import get_precipitation_fields arg_names = ("source", "dry_input", "output_splits_merges") arg_values = [ ("mch", False, False), ("mch", ...
512312869c5faf6ea723cb88b2f863dfde06601c9320e16c034486ccc36ec5f0
Python
3,735
116
#!/usr/bin/env python # coding: utf-8 """Code for Figures 2, 5""" # In[ ]: get_ipython().run_line_magic('Sort', 'by Substrate') import numpy as np import pandas as pd from sklearn.preprocessing import MinMaxScaler, RobustScaler, QuantileTransformer from sklearn.model_selection import train_test_split, StratifiedKFol...
5d6d656c7472536e21b41c82d6a48216307afcc73623113dba62509a0120fdaa
Python
3,735
130
from __future__ import annotations import sys from typing import TYPE_CHECKING, Dict, Optional import imctools.io.mcd.constants as const if sys.version_info >= (3, 8): from typing import TypedDict # pylint: disable=no-name-in-module else: from typing_extensions import TypedDict if TYPE_CHECKING: from ...
1d6895c3c2c0a89c97b19230e628ac802481fb619a04e7b3cec4ef1bc5fd8629
Python
3,738
82
# -*- coding: utf-8 -*- """ ------------------------------------------------------------------------------ Copyright (C) 2019 Université catholique de Louvain (UCLouvain), Belgium. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License....
467b4ce5d193116b1e241fb2efc11521fed7afe3bbce660039f5021a0834872a
Python
3,739
111
from sklearn import svm import pickle import numpy as np # import matplotlib.pyplot as plt # from scipy import stats ### PARAMETERS # output file prefix out_file_pref = 'res_5fold_split_1' # SVM kernel (RBF or Polynomial) # kern_func = 'rbf' kern_func = 'poly' # Polynomial degree for 'poly' ker...
e65c1cc607c6363ac27990ac09f65e1ab9837b97c9ab6ffcdfcf01897a5a4020
Python
3,743
101
# -*- coding: utf-8 -*- # (C) Copyright 2020, 2021, 2022, 2023 IBM. All Rights Reserved. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any...
a923461c9fd2325e48e7bc46c86c173b9ac695ab1822555d27e2b09604aa85ae
Python
3,746
94
import os.path import pytest from click.testing import CliRunner from GANDLF.entrypoints.split_csv import new_way, old_way from . import CliCase, run_test_case, TmpDire, TmpFile, TmpNoEx # This function is a place where a real logic is executed. # For tests, we replace it with mock up, and check if this fun...
888221afc582466adf64f3047feddfc9d7d258c2d25651822a54b27a2468c439
Python
3,747
125
#!/usr/bin/env python3 # Copyright 2021 Alexander Meulemans, Matilde Tristany, Maria Cervera # # 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 ...
95a8d2a5af94c4818858b0272faeef39caf5508f8ee5292393e6366ff1705a06
Python
3,755
147
from matplotlib.pylab import * from joblib import Parallel, delayed import multiprocessing import sys sys.path.insert(0, '../../helpers/') from circ_stats import * from pickle import dump,load import scikits.bootstrap as bootstrap import difflib import seaborn as sns from scipy.stats import circmean from joblib impor...
c4896f9aa276585dd30476d42c4a1b534e2838f17fcde01c5924fa932e357660
Python
3,760
101
from __future__ import absolute_import import numpy as np import scipy.linalg def smooth_with_noise(image, bits): """Smooth the image with a per-pixel random multiplier image - the image to perturb bits - the noise is this many bits below the pixel value The noise is random with normal distr...
1a944bd28a96292a870cfd47004c32ea9616f0caf4f18f39b2759f686dbe1e16
Python
3,763
105
# -*- coding: utf-8 -*- # (C) Copyright 2020, 2021, 2022, 2023 IBM. All Rights Reserved. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any...
e4449b7e6e9f33132ac06a5c23cb4d95f9bf15404561182176598984ea7d0032
Python
3,764
94
#### Master Script 2: Partition CENTER-TBI for stratified k-fold cross-validation #### # # Shubhayu Bhattacharyay # University of Cambridge # email address: sb2406@cam.ac.uk # ### Contents: # I. Initialisation # II. Resampling of dataset for training/testing splits # III. Resampling of training sets to set assign valid...
92553830392cc715de44a1ed5335c53f5cb8f27cb27d178d7d519855189c84d0
Python
3,766
116
import scipy.io as scio import numpy as np import pandas as pd import matplotlib.pyplot as plt from scipy.fftpack import fft,ifft from scipy import signal from scipy.fft import fftshift data = [np.array(scio.loadmat(f'./propofol_circle/cortical_thalamus_simulationpropofol_circle__16000ms_{i}.mat')['Isubregion'...
b1d97916fa94513b71e8b38ca2d1e921fe5598004a1e52e113c3fc0f255b8548
Python
3,767
84
""" ClinicalASL - Clinical Arterial Spin Labeling processing pipeline ASL data preparation module. Repository: https://github.com/JSIERO/ClinicalASL Author: Jeroen Siero Institution: UMCU (University Medical Center Utrecht), The Netherlands Contact: j.c.w.siero@umcutrecht.nl Description: Perform motion correcti...
53046c8528aec6ffa145b7e58ca61d5c6cdc2e1f8a8b132c8db4f26d593be4bc
Python
3,768
96
from setuptools import setup, find_packages from setuptools.command.install import install import os.path import sys VERSION='2.3.3' here = os.path.abspath(os.path.dirname(__file__)) readme_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'README.md') try: from m2r import parse_from_file read...
a4087f35c80ca443e1c7a765110bc2e1fb36609b00423bb246e827a73f73580d
Python
3,773
91
# -*- coding: utf-8 -*- """ molvs.resonance ~~~~~~~~~~~~~~~ Resonance (mesomeric) transformations. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import logging from rdkit import Chem log = logging.getLogger(...
8aa4f88ab84be2247525115e67e312ebad8ab5df299103b081bda265d1c5ae98
Python
3,779
113
import numpy as np import scipy.io import os.path as osp import sys import argparse sys.path.append('..') from nilearn import plotting from functions.def_ROIs_EarlyVisualAreas import roi as ROI from functions.def_ROIs_DorsalEarlyVisualCortex import roi def polarAngle_plot(subject_id, path, cluster, binarize=False): ...
e188d4f0e3b69483cdaa7ed7a59a50e0b292a1c5febd5890580a4a9a4cd995b5
Python
3,779
82
""" ClinicalASL - Clinical Arterial Spin Labeling processing pipeline DICOM to NIfTI conversion module. Repository: https://github.com/JSIERO/ClinicalASL Author: Jeroen Siero Institution: UMCU (University Medical Center Utrecht), The Netherlands Contact: j.c.w.siero@umcutrecht.nl Description: Function for regis...
242af0051628efdff30e4ab0cc3ff0573e2c9bd496bb4f758cacd58671362eb0
Python
3,780
114
''' JHK Python script for computing occlusion sensitivity ''' import numpy as np import os from cdo import Cdo #========================================================== # Set main directory #========================================================== hdir = '/home/jhkim/task/ccd_anom_backup' cdo = Cdo() f_name_lis...
5d4b8be2ef338487e1b51be905f0efb065bfe6aed9afc15fc5b9b66026980456
Python
3,780
90
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Thu Apr 12 09:36:18 2018 @author: saskiad """ # dataset # get spontanoues stim table # get L0 # spontaneous rate # table cell id, cre, area, depth, cre_depth, spontaneous rate import numpy as np import pandas as pd #import os, h5py #import scipy.stats as ...
81298f7129d0aab94f1456b1a9d25d12a5509f690e818820847bc0d07bd6869a
Python
3,780
114
''' JHK Python script for computing occlusion sensitivity ''' import numpy as np import os from cdo import Cdo #========================================================== # Set main directory #========================================================== hdir = '/home/jhkim/task/ccd_anom_backup' cdo = Cdo() f_name_lis...
40fbd376b22d1a1bb85151f91e2c3e56c7e875afb66540fba589e2e06004c705
Python
3,782
99
""" ClinicalASL - Clinical Arterial Spin Labeling processing pipeline ASL Look-Locker correction module. Repository: https://github.com/JSIERO/ClinicalASL Author: Jeroen Siero Institution: UMCU (University Medical Center Utrecht), The Netherlands Contact: j.c.w.siero@umcutrecht.nl Description: Function for comp...
68b6e0716cc0b4258695e810f7dfffdbdf491ea78c83172d0c3366cb1ce0899a
Python
3,783
94
#------------------------------poke_habituation protcol-------------------- #Task file for 5-CSRTT habituation, task starts with reward and trial starts by presenting all light #...of the five-choice light on for undefined time any poke at five_choice give reward # important note:- Do not change any print stings if you...
f2d7d6549fe5946c7747299f7be1790f5e7bbdd4597518d1329ac03e59923130
Python
3,790
109
""" Tools for working with NIDM-Experiment files """ from argparse import ArgumentParser import os.path from rdflib import Graph, util from nidm.experiment.Utils import read_nidm def main(): parser = ArgumentParser( description="This program contains various NIDM-Experiment utilities" ) sub = par...
fecf93cb0b9d3a1db572821eeae6ae0448e2c94ced907f38cdf311057a0b904e
Python
3,791
81
import torch import os import logging import argparse import random import numpy as np def parse_args(): parser = argparse.ArgumentParser() # set data and method parser.add_argument('--data', type=str, default='qm7', choices=['qm7', 'qm8', 'qm9', 'hamiltonian', 'newtonian', 'md']) parser.add_argument(...
bda8d0e62927d22ea1c3c3e4a8019cb888c90837731d8bf402d3ff0394d5ffe5
Python
3,792
111
# coding=utf-8 """ ErodeObjects ============= **ErodeObjects** shrinks objects based on the structuring element provided. This function is similar to the "Shrink" function of **ExpandOrShrinkObjects**, with two major distinctions- 1. **ErodeObjects** supports 3D objects, unlike **ExpandOrShrinkObjects**. 2. In **Exp...
324fd10a8f0fa9a9a14323f6f15e5aac1c976e1d1577ba4dc069dd77211b5c6d
Python
3,793
105
from typing import Optional import torch import torch.nn.functional as F from skimage.measure import label import numpy as np from scipy.ndimage import binary_fill_holes, binary_closing from GANDLF.utils.generic import get_array_from_image_or_tensor def torch_morphological( input_image, kernel_size: Optional[int]...
a6be05355d377ff5697bb23f94b621ddbbb90573916d3757d610f50d3b2ef9ab
Python
3,796
109
import pandas as pd import numpy as np import argparse import matplotlib.pylab as plt from rdkit import Chem import rdkit.Chem.Descriptors import os def pref_split(smiles_string): """ splits a string on '|' into a list with two elements, starting from the right the prefix token must be in '<pref...
1f7fa7ba320de168004a7b2a05d0ee8a8b90d8cf9401c5ddaf72d08a6689a7d1
Python
3,797
142
from typing import Literal, cast import numpy as np import pytest import xgboost as xgb from xgboost import testing as tm from xgboost._data_utils import ArrayInf, from_array_interface, pd_cat_inf from xgboost.testing.ordinal import ( run_cat_container, run_cat_container_iter, run_cat_container_mixed, ...
079f6c2703f515ab354bfb67f5c2c403dcbdcd4804b3085e8afd907621c66ea3
Python
3,799
94
from . GenomeTrack import GenomeTrack from .. utilities import get_optimal_fontsize, change_chrom_names import numpy as np import pyfaidx import os # Color code for seqs seq_color = {'A': 'red', 'T': 'green', 'G': 'blue', 'C': 'black', 'N': 'grey' } cl...
82a6f22a3758e83f3a8a0f7fee7997b7d88607969d8f072dd9f9243cb1086bfb
Python
3,800
108
# -*- coding: utf-8 -*- # (C) Copyright 2020, 2021, 2022, 2023 IBM. All Rights Reserved. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any...
9b3f8f1194a034714d711dfd57bdcf392c15b57554784f6e201aacf27605dea2
Python
3,808
85
import numpy as np import pandas as pd from dragen.utilities.generateExodus import NetCDFWrapper from dragen.utilities.PvGridGeneration import MeshingHelper from dragen.utilities.InputInfo import RveInfo class MooseMesher(MeshingHelper): def __init__(self, rve_shape: tuple, rve: pd.DataFrame, grains_df: pd.Data...
378680947b0ea64704903e54d8e07d082c3b5c39281338b2ad1f85140f4252d9
Python
3,811
138
""" adapted from https://github.com/TissueImageAnalytics/tiatoolbox/blob/master/tiatoolbox/tools/stainextract.py """ from typing import Optional import numpy as np from skimage import exposure import cv2 def contrast_enhancer( img: np.ndarray, low_p: Optional[int] = 2, high_p: Optional[int] = 98 ) -> np.ndarray:...
905790304d38f39589e9ae0fbc2279846cf67351785aabfb7c0dff6bc5c97607
Python
3,813
98
from __future__ import absolute_import import unittest import numpy as np import scipy.ndimage import centriole.smooth as cpms class TestSmoothWithNoise(unittest.TestCase): def test_01_smooth_zero(self): """Make sure smooth doesn't crash on all zeros""" out = cpms.smooth_with_noise(np.zeros((3, 3)...
b883dc8b5d32605e0498b7f9ee6e030903a96f8cdcf95ead3a9bf2095ff3286b
Python
3,813
112
import cupy as cp import rvt.vis import rasterio as rio import time import numpy as np def slope_aspect_gpu(dem, resolution_x, resolution_y, ve_factor=1, output_units="radian"): """ Procedure can return terrain slope and aspect in radian units (default) or in alternative units (if specified). Slope is def...
70c76f3bc13cae39ccfebe18e5c2a66e6e08defc7fd2382d36f7055de5219c18
Python
3,818
92
""" Author: Mingjian He <mh1@stanford.edu> Testing functions for the iOsc algorithm in somata/oscillator_search/iter_osc.py """ from somata.oscillator_search import IterativeOscillatorModel as IterOsc from somata.oscillator_search.helper_functions import innovations_wrapper from somata import OscillatorModel as Osc f...
340a48fb055762dca960f0b87f35e4aa5ed0a49a81fde2ac45b2b3ad62d2cb6a
Python
3,823
111
import os import logging import numpy from deeprank.models.forcefield.param import VanderwaalsParam from deeprank.models.forcefield.patch import PatchActionType from deeprank.parse.forcefield.top import TopParser from deeprank.parse.forcefield.patch import PatchParser from deeprank.parse.forcefield.residue import Res...
9fb7b98b2130884fcd9b1d0f99dd3fbfb9791d0aad05b64175d1055d12f1a4e8
Python
3,826
123
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Oct 29 15:27:11 2018 @author: Nikolai M Chapochnikov """ file_hdf = 'results/act3.hdf' n_cells = 21 n_conc = 5 n_odors_EC = 34 # this is the order based on the 2nd loading vector of the PCA of ORN activity # when the full activity data (all concent...
9adfe55332945deb3f9b19c9a592bdba54be0fae4f2a8c11ea503776a5c04d8c
Python
3,829
96
import pyb import math from . import hardware as hw _sine_len = 100 # Number of points in sine wave. _sine_buf = bytearray([128+int(127*math.sin(2*math.pi*i/_sine_len)) for i in range(_sine_len)]) _sqr_buf = bytearray([255,0]) _click_buf = bytearray([255,0,255,255,0,0]+4*[255]+4*[0]+8*[255]+8*[0] ...
f0214f5327a22921e92e6bc0f06c21fa55a568b3e88a2c05600a6ca9b51d2e17
Python
3,832
120
import logging from sklearn import svm, linear_model from sklearn.ensemble import AdaBoostRegressor, RandomForestRegressor from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier from sklearn.gaussian_process import GaussianProcessClassifier from sklearn.linear_model import Ridge, ElasticNet, Lasso, SG...
31ed82f5d3803c33d65f34340a12fc92ec8fc348f2a8514cf0a943746b9d7b55
Python
3,835
114
""" TanH Scheduler TanH schedule with warmup, cycle/restarts, noise. Hacked together by / Copyright 2021 Ross Wightman """ import logging import math import numpy as np import torch from typing import List, Tuple, Union from .scheduler import Scheduler _logger = logging.getLogger(__name__) class TanhLRScheduler(...
5c3d08d6c32539569ca50580335bff6ccd760035b9e604bad9fda6d9cf70b173
Python
3,848
109
# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup -------------------------------------------------------------- # If ex...
7cd99a6b39c4098929e95e76c8905abc2d790b4bb5496e02080670e73d114410
Python
3,849
93
import numpy as np import torch import torch.nn as nn from torch.autograd import Variable from torch_geometric.utils import to_dense_adj, degree from scipy import sparse as sp def Laplacian_position_encoding(edge_index, num_nodes, pos_enc_dim): """ from https://github.com/graphdeeplearning/benchmark...
14d50142ac9960abaa8f718382cedfb9a962fa6ed5c796c9f3eb707c84620e6e
Python
3,850
94
# -*- coding: utf-8 -*- import numpy as np from . BedGraphTrack import BedGraphTrack from . GenomeTrack import GenomeTrack class BedGraphMatrixTrack(BedGraphTrack): # this track class extends a BedGraphTrack that is already part of # pyGenomeTracks. The advantage of extending this class is that # we can r...
732b813b3ce135c55da59583bb6daf82d33ee63aed0bc1a32e16054166e62fcf
Python
3,852
147
import pdb import wntr import torch import networkx as nx from DT_for_WDN_leak_localization.network import WDN def get_prior(net, data_path): epanet_data_path = f"EPANET_input_files/net_{str(net)}.inp" if net == 1: return get_prior_net_1(data_path, epanet_data_path) elif net == 2: ...
59ebf6afff2c5798552d3dc061635f20a82869e55e768a56e96830186741b923
Python
3,853
120
import hashlib import numpy from ..image import Image from ..module import Module from ..setting.text import Name class InjectImage(Module): """This module is intended for testing. It injects an image into the image set. """ module_name = "InjectImage" variable_revision_number = 1 def __in...
66617edd8eee1f1260c037b39647773544bc66ffc4e09b15c1dc96ff341d1385
Python
3,856
162
import numpy import pytest import skimage.data import skimage.color import skimage.filters import skimage.measure import cellprofiler_core.image import cellprofiler_core.measurement import cellprofiler_core.object import cellprofiler_core.pipeline import cellprofiler_core.workspace @pytest.fixture( scope="modul...
fa4e7b07f933dc1adeccc24cca82f4b5ac462b5418a1c9e3f34f905fbc6121a9
Python
3,856
113
import sys import torch sys.path.append("..") import utils spike_args = {} spike_args['thresh'] = utils.args.thresh spike_args['lens'] = utils.args.lens spike_args['decay'] = utils.args.decay class Net(torch.nn.Module): def __init__(self, args, inputsize, taskcla, labsize, nhid,nlayers=1): ...
183aa8670651d5fba8f6eda8a779979bd21e36dadcf929824c5ac4f7c622a997
Python
3,862
116
""" created by: Donghyeon Won """ from __future__ import print_function import os import argparse import numpy as np import pandas as pd import time import shutil from PIL import Image from tqdm import tqdm import torch from torch.utils.data import Dataset, DataLoader from torch.autograd import Variab...
2d50879305ea260722e537da1e8951d1cebcad159d64f25a9cc2a1fe08f30d31
Python
3,864
115
""" FillObjects =========== **FillObjects** fills holes within all objects in an image. **FillObjects** can be run *after* any labeling or segmentation module (e.g., **ConvertImageToObjects** or **Watershed**). Labels are preserved and, where possible, holes entirely within the boundary of labeled objects are filled ...
7c73cfb124ac785118596410a06c57f0327025a7fc1f301b27480b6d07bde3db
Python
3,864
133
# -*- coding: utf-8 -*- """ pysteps.io.archive ================== Utilities for finding archived files that match the given criteria. .. autosummary:: :toctree: ../generated/ find_by_date """ from datetime import datetime, timedelta import fnmatch import os def find_by_date( date, root_path, p...
f5c44a3e636099e5dafef4672f982473a830e313d9e487ce71aadef9c2b336a5
Python
3,866
143
import torch import torch.nn as nn # sub-parts of the U-Net model import torch import torch.nn as nn import torch.nn.functional as F from torchfcn.models import FCN8s class double_conv(nn.Module): '''(conv => BN => ReLU) * 2''' def __init__(self, in_ch, out_ch): super(double_conv, self).__init__() ...
30782659d41f887a852e94e882f2e2c09fec0a68075b2fcb4b129532a837263d
Python
3,867
104
import numpy as np from functools import partial from scipy.stats import beta, expon import bayesflow as bf from priors import sample_random_walk, sample_scale from likelihoods import sample_poisson_process class RandomWalkPoissonModel: """A wrapper for a non-stationary Poisson process with a random walk transi...
540706480af74d330d58bc887104c1fe42f7ae4e5f730503bca184870c5f4a68
Python
3,869
113
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Oct 5 15:58:38 2021 @author: filtsem """ from pathlib import Path import numpy as np import eelbrain import re import os import mne import pandas as pd from mne.stats import (spatio_temporal_cluster_test, f_threshold_mway_rm, f_mway_rm) from mne impo...
6f218baa5863b826663ee28683617f2a3703ba3d33a70e8bdd314bc0b8d92f88
Python
3,869
129
""" This file implements functions to simulate and analyze Fitzhugh-Nagumo type differential equations with Brian2. Relevant book chapters: - http://neuronaldynamics.epfl.ch/online/Ch4.html - http://neuronaldynamics.epfl.ch/online/Ch4.S3.html. """ # This file is part of the exercise code repository accompanying # t...
79406f6802dbdfe51571e69a3859d6b7de8349c8b6a965359d8bfc3f93e56ca9
Python
3,869
116
# -*- coding: utf-8 -*- # (C) Copyright 2020, 2021, 2022, 2023 IBM. All Rights Reserved. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any...
01063d9d6fbb49fd03a5135263cfd4682fb581d69484fc6446806fec67ad7d72
Python
3,872
62
import argparse import ast class Options: def __init__(self): self.parser = argparse.ArgumentParser() # logging options self.parser.add_argument('--config_file', default='config.yaml', type=str, help='path to config file') self.parser.add_argument('--data_config', type=str, help='...
6b3d5627f6cc250bb982a144955fb2de3ce7bb9f7e354081ddfeb987a443fff4
Python
3,875
95
import sklearn.metrics import matplotlib.pyplot as plt import numpy as np import tensorflow as tf import itertools def numeric_metrics(model,dataset,threshold=0.5,drop_carbon=True): for data, labels in dataset.take(1): y_pred = model.predict(data,verbose=0) y_true = labels for data, l...
982ef2509b044f84c3d1770543e35e2b6461622db38669a4de35df6964aac6f8
Python
3,875
110
import glob import logging import os import re import shutil from pathlib import Path from typing import Sequence, Union from imctools.data import Session from imctools.io.mcd.mcdxmlparser import McdXmlParser from imctools.io.ometiff.ometiffparser import OmeTiffParser from imctools.io.utils import OME_TIFF_SUFFIX, SCH...
026afbe74caab8f5a6c0e429bc86508673a3b9f0242aadb9996211fbfe36d4a5
Python
3,876
106
import numpy as np from scipy.ndimage import (binary_closing, binary_dilation, binary_erosion, binary_opening) a = np.array([[1, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 1, 0], [1, 1, 0, 0, 0, 0, ...
03db9e67dd9d62f593cdfea9b831782faf73df04e744b89b93620fb18f830e42
Python
3,876
62
import argparse import ast class Options: def __init__(self): self.parser = argparse.ArgumentParser() # logging options self.parser.add_argument('--config_file', default='config.yaml', type=str, help='path to config file') self.parser.add_argument('--data_config', type=str, help='...
7f23f5aa46522a4b3df526c2b840570b2a4e09f4a429ce2e627a5f72d0f33558
Python
3,877
102
from typing import Sequence, Type, Union import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import LayerNorm from monai.networks.layers import Conv, trunc_normal_ from monai.utils import ensure_tuple_rep, optional_import from monai.utils.module import look_up_option R...
a81dcf8618a4064489d10d83b3ccff2bc97f48c9d56936f79f4d598261bbc338
Python
3,878
108
import keras from keras.models import Sequential from keras.layers import Dense, Dropout, Activation, Flatten from keras.layers import Conv2D, AveragePooling2D, BatchNormalization from keras.callbacks import EarlyStopping, ModelCheckpoint from keras.models import load_model import numpy as np import matplotl...
161a3e96f7465ebdc5a66b857effa3041a00d817e0c08a0aa23164cd68a97eda
Python
3,887
44
from .base_options import BaseOptions class TrainOptions(BaseOptions): """This class includes training options. It also includes shared options defined in BaseOptions. """ def initialize(self, parser): parser = BaseOptions.initialize(self, parser) # HTML and tensorboard visualization...
4d0302753785ed362d5a6f435882bdcf7a4246a4f043c96528cfb616ef5cffc3
Python
3,890
88
import tensorflow as tf from .layer import GradientLayer,BoundaryGradientLayer class PINN: def __init__(self, network): self.network = network self.grads = GradientLayer(self.network) self.boundaryGrad = BoundaryGradientLayer(self.network) def build(self,NO_FLUX_BND,RADIALDIFFUSI...
70fb4c20282680c242fdd1205b6bafd1e6dbe79b9a2016d69aa96fac03ec55cf
Python
3,891
160
""" Top-level trial data bandpower export Authored by Eric Easthope """ import numpy as np from pathlib import Path DATA = "data" DERIVED = "derived" fs = 3052 MIN_REST_LEN = 1 / 2 bandnames = [ "beta1", "beta2", "gamma1", "gamma2", "highgamma1", "highgamma2", "beta", "gamma", "h...
2547e79fe476c295d800cc039fbc7e8c3bb81523b29ac06850cc636e0ec84105
Python
3,892
104
import os import scyjava import numpy as np import logging from . import omexml from ..utilities.java import jimport LOGGER = logging.getLogger(__name__) p2j = lambda v: scyjava.to_java(v) def write_image( pathname, pixels, pixel_type, c, z, t, size_c, size_z, size_t, channe...
626e9dc0ca775bb863063cf5f0dfdd08ede215fbd73747a0f2479fbf3f5bc567
Python
3,900
110
# -*- coding: utf-8 -*- # (C) Copyright 2020, 2021, 2022, 2023 IBM. All Rights Reserved. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any...