sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
d061449443e33ce2f51bc6a42304f930159dfab473b815be567194155f3dfec3 | Python | 4,984 | 167 | # Diana Giraldo
# Aug 2023
# Last update: Dec 2024
from time import time
import numpy as np
import cv2
from .utils.reconstruction import combine_volumes, pad_rgb_channels, combine_channels
from .utils.image_slices import ImageSlices
from .utils.affine_transform import adjust_affine_transform
from .apply_models import... |
fa22365aeaf873fe223af7323b0ebd74b41ba1c87a531ac7ad0fa169d7e2c652 | Python | 4,984 | 220 | #
# MIT License
#
# Copyright (c) 2022 GT4SD team
#
# 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,... |
fde14c6ede11fd22760af29781b9ef83c80b81d5a3ce8416ce4d8fd0be4f39c8 | Python | 4,984 | 139 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This Python script is used to extract the timeseries from functional
images preprocessed by fmriprep.
This pipeline will generate timeseries files, framewise displacement record
and the labels of the used Atlas.
Schaefer 400 Atlas is used by default.
Note!!!!!!!!!... |
1f1db26c047ef81a39f6c99458bf94d1733d012d79502e9ea61081e5bdeec35a | Python | 4,985 | 175 | import os
import re
import urllib2
import numpy as np
def download(url, filename, mkdir=False, verbose=True):
page = urllib2.urlopen(url)
data = page.read()
dirname = os.path.dirname(filename)
if mkdir and not os.path.exists(dirname):
os.mkdir(dirname)
with open(filename, 'wb+') as f:
... |
49419d767068edf8e10882655674bd95db8586d84d5e0e731d9a790d67b046fc | Python | 4,985 | 116 | #!/usr/bin/env python3
"""
Generate a copy of ddG-backrub.xml that additionally reports per-chain energies.
Why
---
The `unbound_wt` / `unbound_mut` totals in ddG.db3 are whole-pose scores. InterfaceDdGMover
builds the unbound state by rigid-body translating the moving chain(s) 1000 A apart, without
repacking or re-mi... |
bb1ece4f017d6a3016aa58e4d6811ecd9540fb5f9848e70b1806170add0f1888 | Python | 4,985 | 120 | """Implementation of the device configuration models."""
from pathlib import Path
from typing import Annotated, Literal
from pydantic import BaseModel, Field, model_validator
from pypulseq import Opts
# Ensure that max. amplitude is within 1 and 6000 mV (step size 1 mV).
# Limits depend on card version.
TxAmplitudeTy... |
ed80db9c49066be17cdce3924685c1b042c1406d1f310e54228a5481af3840ba | Python | 4,986 | 203 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# 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 applicab... |
39f6c143ffce9bccd1b16c40f223688c51794b287ccb9798034916907eabf8e5 | Python | 4,987 | 94 | """
FLYWIRE_CELLTYPE_CONTROLS.py
Uses 06-OUTPUT/id_join_mat571_v783.parquet to put PUBLISHED CELL TYPE LABELS on the
full-scale determinacy table for the first time. Replaces the hemibrain anatomical
proxy with the real thing.
Two named controls the field already agrees about:
KENYON CELLS - known cholinergic, pre... |
52c893f28caf8db20d2d6c04fba4f7610e0793fd9fecb1b48c89a288f78fb3c7 | Python | 4,987 | 155 | # Node-group asset "Ambient Occlusion Internal" (ShaderNodeTree), dumped by nodebpy.assets.dump_library.
# Rebuild the library with nodebpy.assets.build_library (nodebpy build).
# _build_group() is the source of truth: the docstring, __init__ and accessors are regenerated from it on the next dump.
from typing import TY... |
ee4870a450e755a9f3b2a965a0741952d5c958c0e9944fa90f8a193f6bce8ffa | Python | 4,987 | 146 | """
Script for inserting template matching results (scores y angles) in a SynGraphMCF
Input: - SynGraphMCF
- Template matching output(s) (Pytom)
- Refinement parameters
Output: - Graph with template matching information inserted as vertex and edge properties
"""
__author__ = 'A... |
b2a5b3f224b2718af0274c6eabeb8409a0a4fc3bb57310c9c94628b4128d6b56 | Python | 4,988 | 131 | #Build an index dictionary for sequence position -> reference position & signal position
import re
import pysam
import pod5
import pysam
import pickle
import shelve
import zlib
from collections import defaultdict
from tqdm import tqdm
import numpy as np
DATA_TYPE = np.int32
def get_hc(read):
cigar_string = read.c... |
20cc39a950840b83a3ca29fcbffaa5f936499028dfd7450e201f9205c3d23ef5 | Python | 4,989 | 145 | import glob
import os
import subprocess
import sys
import tempfile
from distutils import log
from distutils.errors import DistutilsError
from functools import partial
from . import _reqs
from .wheel import Wheel
from .warnings import SetuptoolsDeprecationWarning
def _fixup_find_links(find_links):
"""Ensure find-... |
2a67f775e2b98ce9badc08e5502eec5941234f5fbef1f3fd125e244deaf98990 | Python | 4,989 | 177 | """Efficient comparison metrics for fingerprints and their databases.
Author: Seth Axen
E-mail: seth.axen@gmail.com
"""
import logging
from ..fprint import Fingerprint
from ..util import E3FPBitsValueError
from ..db import FingerprintDatabase
from . import array_metrics
from . import fprint_metrics
def tanimoto(A, ... |
1996ed8211b07c41884ac0567137eb6e4676bc3a73a688710c82b496f01412af | Python | 4,991 | 147 | #
# MIT License
#
# Copyright (c) 2022 GT4SD team
#
# 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,... |
3cbd36bde7488df455cf5f41e65d2f92dd89a65487a81aa42c6008a239e9adae | Python | 4,991 | 169 |
import numpy as np
import random
from scipy.signal import resample
class Compose(object):
def __init__(self, transforms):
self.transforms = transforms
def __call__(self, seq):
for t in self.transforms:
seq = t(seq)
return seq
class Reshape(object):
... |
67645ca8e0f40ca9f7587a29447b6fffa71df86db2d57e2c242686f4ddbf3ddd | Python | 4,991 | 169 | # Node group ".utils_group_field_at_selection" (GeometryNodeTree), dumped by nodebpy.assets.dump_library.
# Rebuild the library with nodebpy.assets.build_library (nodebpy build).
# Shared by several assets, which import it; not an asset itself.
# _build_group() is the source of truth: the docstring, __init__ and access... |
6c825df1647606532e85ff458415ed9c3a2b3ea2d42c9685eb9154830b0b96c9 | Python | 4,991 | 104 | """Metric glossary, thresholds, status, and banner for the registration report.
Stdlib only; never raises. Threshold cutoffs are soft QC hints, not verdicts."""
import csv, json, os
from regtools.registration.report.assets import _esc
METRIC_HELP = {
"Dice": "Overlap of registered vs atlas labels (0–1). Hi... |
88fb0d5074b73ef068b51b6bb7b0d99c7f293c7715b8ee3eb5b490b3cbd5b363 | Python | 4,991 | 118 | #!/usr/bin/env python
# coding: utf-8
import argparse
import pandas as pd
import random
import numpy as np
from keras import models, layers, regularizers
from sklearn.model_selection import KFold
from sklearn.preprocessing import StandardScaler
from sklearn.metrics import confusion_matrix
# Set up argument parser
par... |
ceaf2ec245163b1a3fdd0d998665614891ae9042fe6d2ce32ce395448949cec7 | Python | 4,993 | 117 | # set QT_API environment variable
import os
os.environ["QT_API"] = "pyqt5"
import qtpy
# qt libraries
from qtpy.QtCore import *
from qtpy.QtWidgets import *
from qtpy.QtGui import *
# app specific libraries
import control.widgets as widgets
import control.widgets_tracking as widgets_tracking
import control.camera_TI... |
a9bea86310e0c075ad06b5719bc63dca196733214ec762ec7cfc77c49c9dc946 | Python | 4,994 | 134 | #!/usr/bin/env python3
"""Score curated metabolic transcriptional programs in SEA-AD Micro-PVM nuclei.
Scores are the mean gene-wise standardized log-normalized expression within
each curated gene set. Gene-set versions and retained genes are written to
disk so the calculation can be reproduced exactly.
"""
from path... |
32ef0021298b0f513758d5192a76fcbec6cd4c43249db82a70c686d67b01e82b | Python | 4,995 | 147 | import unittest
import numpy as np
from neurolib.models.hopf import HopfModel
from neurolib.control.optimal_control import oc_hopf
import test_oc_utils as test_oc_utils
p = test_oc_utils.params
class TestHopf(unittest.TestCase):
"""
Test hopf in neurolib/optimal_control/
"""
# tests if the control... |
08e03e9bf5518d7eda03e7e759f3173494386020146b47458fe847ab4b8f0382 | Python | 4,997 | 193 | import numpy as np
from swift import aswift
class DBS(object):
def __init__(self, dt=1e-3, stim_amp=1, width=60, tstart=0):
'''
Initialize a DBS object
Parameters
----------
| stim_amp : float
| Stimulus puse amplitude (mA)
| width : float
| ... |
07ee9c57e9aa1f73907d5f956f48a708853a39d91ec52e5db1e35b1d25113458 | Python | 4,999 | 124 | import pandas as pd
import numpy as np
from sklearn.cluster import KMeans
import matplotlib as mpl
from scipy.stats import zscore, ttest_rel, ttest_ind
import seaborn as sns
from matplotlib import pyplot as plt
from sklearn.metrics import silhouette_score
import matplotlib
import matplotlib.ticker as mticker
import os ... |
18186b415eb6e17fe2542b0e800fb5e43739b72fb3de54f108bd9e55392d41b0 | Python | 5,000 | 107 | """Regression tests for multi-optical-plane ("layers") section expansion.
A TissueCyte folder holds ``layers`` optical planes per physical cut, stacked
layer-major: the first ``mrows*mcolumns`` sorted tile indices are plane 0, the
next block is plane 1, etc. ``get_section_data`` must emit one stitched section
pe... |
866e8ad6cf8319f737540204332945ac3248e04d50cded762e590d44c56659bf | Python | 5,000 | 103 | import os
from copy import copy
from typing import Union
import numpy as np
import pandas as pd
from sklearn import model_selection
from torcheeg.datasets.module.base_dataset import BaseDataset
def train_test_split_per_subject_cross_trial(
dataset: BaseDataset,
test_size: float = 0.2,
subject... |
94e2bd28b7a3b4e0e6e6ffc481ed09c816abcab2785301e92b0a5d74a412086a | Python | 5,000 | 180 | import os
import six
import random
import pytest
import numpy as np
from skimage.io import imread
from keras_applications.imagenet_utils import decode_predictions
if os.environ.get('TF_KERAS'):
import tensorflow.keras as keras
from classification_models.tfkeras import Classifiers
else:
import keras
fr... |
e026b1160375045e7db532fe633edb092a684292ed4a0ff4e1c2473d94001da8 | Python | 5,000 | 164 | """
Script for getting and quantifying patches directly attached to one side of a membrane
Input: - Pickle file with a GraphMCF
Output: - Pickle, VTK, GT and subvolumes files with attached structures separated
according to anchor shortest distance criteria
"""
__author__ = 'Antonio Martin... |
e0e29e624a7e701df2f7d88a88564c89f56c7370b29fafb2c86fed620a26eff4 | Python | 5,000 | 94 | """SPECTRAL_LAW.py 2026-09-30. Pre-registration: 04-NOTES/PREREG-2026-09-30j-SPECTRAL-LAW.md
Can a number computed from the signed wiring alone predict the antennal-lobe runaway found by PHASE_MAP, in FlyWire and BANC?
P1 = Perron root of the excitatory block, P2 = largest real eigenvalue of the full signed matrix, P3 ... |
39dda4d4a79627e0755e805bf08f3ead4077fc9ecdec78ed13b00ea6239bde9d | Python | 5,001 | 149 | # Parameters
import argparse
# Create an ArgumentParser object
parser = argparse.ArgumentParser(description='KNN models for pseudobulk data')
# Add parameters to the parser
parser.add_argument('--inPath', type=str, help='Folder with the input data')
parser.add_argument('--resultsPath', type=str, help='Folder to save ... |
60434d36ad65341e2e41e254255808cf4ab88daae36c09e8c4a580c0a796d8a5 | Python | 5,001 | 105 | # set QT_API environment variable
import os
os.environ["QT_API"] = "pyqt5"
import qtpy
# qt libraries
from qtpy.QtCore import *
from qtpy.QtWidgets import *
from qtpy.QtGui import *
# app specific libraries
import control.widgets as widgets
import control.camera_TIS as camera
import control.core as core
import contr... |
60e7d6f9356d6890a640feefd04d0a59e308ad6796efa2dd9bc4f35b47713feb | Python | 5,001 | 136 | from sklearn.metrics import cohen_kappa_score
from statsmodels.stats.inter_rater import fleiss_kappa
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from matplotlib.ticker import MultipleLocator
# Scores assigned by pathologists for three tasks (Artifact Detection, ... |
82630d3ab1e610e442aea69a6614cee7da672d2a8e64bcaec36ca615b20fbe82 | Python | 5,001 | 164 | from collections.abc import Iterable
import pytest
from elasticai.creator.ir2vhdl import EntityTemplateDirector
@pytest.fixture
def dummy_vhdl_prototype() -> Iterable[str]:
return [
"library ieee;",
"use ieee.std.numeric.all;",
"use ieee.logic_1644.all;",
"use work.skeleton_pkg.a... |
3861d3d4eaf827c9c94f03be3a49d518858b5ac0ab998caa1e5cdb001fd8c65d | Python | 5,002 | 115 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' Perform ICA decomposition to identify and exclude EOG and ECG components '''
import numpy as np
import mne
import matplotlib.pyplot as plt
from mne.preprocessing import ICA, create_ecg_epochs, create_eog_epochs
from sys import argv
def runICA(in_fname,out_fname,ICA_d... |
296129d83001f048a850b50c9f083f4ea51fa7bf278925df473f32362b02605b | Python | 5,003 | 157 | import os
import numpy as np
import torch
import torch.nn as nn
from torch.utils.data import Dataset
from torch.optim.optimizer import Optimizer
import torch.optim as optim
from Operators import *
import tifffile
def makedirs(dirname):
if not os.path.exists(dirname):
os.makedirs(dirname)
def SNR(g... |
74c8a5d639b116e9dd1e416aec50ec3b677d12ac834a68ee45957c91f86851fb | Python | 5,003 | 139 | import torch
import numpy as np
from .base import RadialLayer, CutoffLayer
from torch import nn
from typing import List, Callable, Optional
__all__ = ["ChebyshevPoly",
"SpinChebyshevPoly",
"BesselPoly",
"MLPPoly"
]
class ChebyshevPoly(RadialLayer):
"""
Atomic clus... |
8d192346e4377a997243fdf2599647900845b9574c0086e770bb9076fa4d8f17 | Python | 5,003 | 121 | # -*- coding: utf-8 -*-
"""
Created on Monday June 12th 2023
@author: Pablo Maceira Elvira
Knee bend detection
This script generates a data frame containing the speed and the accuracy of each participant in the baseline block
and in the first block of training, as well as a series of parameters resulting fr... |
e49e6c784f1558c1bce2d12bc8ff6d51878d29bc94a7dae4f0f28d5b405303de | Python | 5,003 | 77 | """AMOUNT_OR_IDENTITY.py 2026-09-29. Pre-registration: 04-NOTES/PREREG-2026-09-29j-AMOUNT-OR-IDENTITY.md
Does the laboratory prior fit the real fly because of WHICH local neurons are excitatory, or only HOW MUCH excitation?
Matched random sign sets (by output share and by cell count) vs F4; Seki real input; AL cut-ou... |
fed151076ca1565a70efbcbcdbb2e3fc77636abdca28031febcf854262d1adfa | Python | 5,003 | 137 | """Utilities for manipulating HedString objects."""
import re
from hed.models.hed_string import HedString
def gather_descriptions(hed_string):
"""Remove any description tags from the HedString and concatenates them.
Parameters:
hed_string(HedString): To be modified.
Returns:
str: The c... |
e4e34b6f20f7152be0d8fd4a6f1af544ea6a9c0720d6376ba7faf74c5d29df5d | Python | 5,004 | 148 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# 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 applicab... |
f4285f913634ffd5b122d43472e2bb174e7ebd04c3f350d608e2d32a3edfb703 | Python | 5,004 | 115 | """Evaluation of predicted event-time quantiles."""
from __future__ import annotations
import matplotlib.pyplot as plt
import numpy as np
from SurvivalEVAL.evaluations.calibration import km_calibration
from SurvivalEVAL.evaluations.custom_types import NumericArrayLike
from SurvivalEVAL.evaluations.util import check_... |
5f943ba7ff6eebf861db7d9cc894908aa58d65ac907bdcee9ed4f55aa68efbfa | Python | 5,006 | 123 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Figure 1 of paper Functional subnetworks
@author: felipe
"""
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
#np.savez('KOPandFreqHeatmaps.npz', kop_mean=kop_mean,kop_std=kop_std,pf_mean=mean_pf,
# pf_sd=sd_pf,pf_ko... |
97e720ead0673e26b4e44e78cb12a4958972eaac500c5a3d5c69031efd9d2db6 | Python | 5,006 | 109 | import argparse
import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
import random
from dataloaders.data_loader_hyper import NetDataset, NetDataset2
from torch.utils.data import DataLoader
from model.resinf import ResInf
from engine import *
parser = argparse.ArgumentParser()
parser.add_arg... |
bf99ffbe4607a4a35ea32cfbedcd52c326e46d36af5badd5dcad7183e5a50769 | Python | 5,007 | 123 | import os
from optparse import OptionParser
### help and usage ###
usage = "usage: %prog [options] args"
description = '''Function: calculate divergence for sites of each annotation category '''
version = '%prog 07.27.2021'
parser = OptionParser(usage=usage,version=version, description = description)
parser.add_optio... |
075c96a8ce7b5c5449172b0cd77eb298bfc5a8b24ed7a4027f65f22bf0f36de5 | Python | 5,008 | 147 | # Parameters
import argparse
# Create an ArgumentParser object
parser = argparse.ArgumentParser(description='Random Forest models for pseudobulk data')
# Add parameters to the parser
parser.add_argument('--inPath', type=str, help='Folder with the input data')
parser.add_argument('--resultsPath', type=str, help='Folde... |
239ff73f74c34fcec7c37f7aec2e9ac983cf4faf48fc956180a84623b1b37bc0 | Python | 5,008 | 140 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# 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 applicab... |
024ce63a7a409e7a669c177be30a6e5a1e21c314bc51d7afbcde45789147e26f | Python | 5,009 | 148 | import os
import pytest
import shutil
import glob
from merlin.core import dataset
from merlin.analysis import testtask
import merlin
root = os.path.join(os.path.dirname(merlin.__file__), '..', 'test')
merlin.DATA_HOME = os.path.abspath('test_data')
merlin.ANALYSIS_HOME = os.path.abspath('test_analysis')
merlin.ANALYS... |
d68243c7effbbf34ccb095e0c5d211dce7b80762e14e65100c5b6385714f8340 | Python | 5,009 | 131 | #!/usr/bin/env python
# coding: utf-8
import os
from pydoc import classname
import numpy as np
import pandas as pd
import argparse
import numpy as np
import pandas as pd
import sys
from tabulate import tabulate
from constants import *
from src.training.train_utils import Logger
from src.models import get_classifier
... |
ca39d4823980581111012dd32e6b12b99fb813a6d515b33601eaefef9d01d7df | Python | 5,010 | 43 | import numpy
# Fixed parameters
protoparams_fixed = { 'Duration': 9240000, 'tolerance': 1e-6, 'Ca_input_onset': 7200000}
# Stimulus protocols: HFS (100 Hz, 1 s)
protoparams_var = { # [0]
'Ca_input_Ns': [100],
'Ca_input_freqs': [100],
'Ca_input_Ntrains': [1],
'Ca_input_trainTs': [1... |
dbe501ea9140bd3ea6de535ec81f724831504ff7fdb81227047f102275d5a65a | Python | 5,010 | 135 | """
Reload (relink) the Python-side session entity for an entity object.
When a ``.blend`` file is opened, the Blender objects for molecular entities are
restored, but the Python objects that back them in the ``MNSession`` (holding the
biotite ``AtomArray``, MDAnalysis ``Universe``, etc.) may be gone. Reloading
recons... |
e7b10e9a672b76908a950db27058583d99a913b1841245320bd4ea5d7ae2b1f3 | Python | 5,010 | 147 | # Parameters
import argparse
# Create an ArgumentParser object
parser = argparse.ArgumentParser(description='Linear discriminant analysis models for pseudobulk data')
# Add parameters to the parser
parser.add_argument('--inPath', type=str, help='Folder with the input data')
parser.add_argument('--resultsPath', type=s... |
ff161fd12ee8c96fc2662b42c88d2abf57b8b287e4ea28bd0b63a7bc0b823606 | Python | 5,010 | 142 | #!/usr/bin/env python
#CheckV Copyright (c) 2020, The Regents of the University of California,
#through Lawrence Berkeley National Laboratory (subject to receipt of
#any required approvals from the U.S. Dept. of Energy). All rights reserved.
import time, resource, platform, sys, argparse, gzip
def parse_seqs(path):
... |
1e4d70cacb3fc2ca90ebf40e19953f03bbcab9811adce3cc84e2052336627dba | Python | 5,011 | 159 | """
Helpers and tools for Syncopy data classes
"""
import os
from numbers import Number
import numpy as np
# Syncopy imports
from syncopy import __storage__, __storagelimit__, __sessionid__
from syncopy.shared.errors import SPYTypeError, SPYValueError
__all__ = ["TrialIndexer"]
class TrialIndexer:
def __init__... |
ef598543f245ac343ea32d659830e8120dc6503b838ec39daccc38cb1fcd0c42 | Python | 5,011 | 96 | import warnings
warnings.filterwarnings("ignore")
warnings.filterwarnings("ignore", category=UserWarning,
message="A NumPy version >=1.18.5 and <1.25.0 is required for this version of SciPy*")
import os
import argparse
import nibabel as nib
from glob import glob
from pyrelimri import brain_icc
... |
7577517460d3d6fbc8d0a9a9c50617590ea8ce742df91af5a9ed3fd0f500ee26 | Python | 5,012 | 149 | from collections import Counter
import torch
import torch.nn as nn
import torch.optim as optim
import numpy as np
import pandas as pd
import diopy
import scanpy as sc
import random
import anndata
import cosg
from torch.utils.data import DataLoader, TensorDataset
device = torch.device("cuda" if torch.cuda.is_available(... |
374a63542a8ef4f96ebf91b752d61b19a55a00b12c844087c86cfe31a42210d0 | Python | 5,013 | 169 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
import os
import numpy as np
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
import seaborn as sns
import pancancer_evaluation.config as cfg
import pancancer_evaluation.utilities.analysis_utilities as au
get_ipython().run_line_magic('load_ext', ... |
65c04f9e9fabf9c59255318c08e2faaa2821dbf6e600662e228bed2794396529 | Python | 5,013 | 123 | import numpy as np
import torch
from torch import nn
def EntropyLoss(input_):
mask = input_.ge(1e-6)
mask_out = torch.masked_select(input_, mask)
entropy = -(torch.sum(mask_out * torch.log(mask_out)))
return entropy / float(input_.size(0))
def Entropy(input_):
epsilon = 1e-5
entropy = -input_... |
9d56e307ed9bac90f04cc98eb339463a8987c7cadb11d4c21930e18724f0fbd6 | Python | 5,013 | 165 | """
Python script to change the segmentation numbers to lower numbers
(sequential values) and removing segmentations that are not
relevant
"""
import nibabel as nib
import os
import sys
import numpy as np
# REMOVED:
# Cortical white matter, cerebellar white matter,
# ventricles, BrainStem, CSF
# VentralDC out
# Choro... |
680d2ffe9b16e8a648dcdd7c4ca0e27f178bea6705f040d770f5c3588e2f8554 | Python | 5,014 | 146 | """
pygments.formatters.rtf
~~~~~~~~~~~~~~~~~~~~~~~
A formatter that generates RTF files.
:copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from pip._vendor.pygments.formatter import Formatter
from pip._vendor.pygments.util import get_i... |
0ea37a30b5bf93abd6841e523b9610beaae18b4857990e48b32b243d131dfcbf | Python | 5,015 | 137 | # ----------------------------------------------------------------------
# Copyright (C) 2016, Numenta, Inc. Unless you have an agreement
# with Numenta, Inc., for a separate license for this software code, the
# following terms and conditions apply:
#
# This program is free software: you can redistribute it and/or mo... |
3dbceee6f342fe62e5d389b98da78a6f4ae1bba89c72d4fe9eb8076b220ee84d | Python | 5,015 | 130 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# 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 applicab... |
917eaf483dd920e09c0e6a9dd84ca8450a619bc25053625c0a0bcb64b8d67947 | Python | 5,015 | 153 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 13 2019
@author: jmagraner
"""
# %%
from autograd import grad
from autograd.misc.optimizers import adam
import autograd.numpy as np
def fitmodel(params,target,specs):
### Define tensor product ###
def TFRmodel(params):
... |
9c73440b5c3f5134083d3f598762c297f522ede2d6a5ef9ac533cb95bbf62e2e | Python | 5,015 | 164 | """"""
import abc
import inspect
class BaseConfig:
""" Base class for all configurations. """
def __init__(self, **kwargs):
""" Constructor. """
# TODO Replace with self.kwargs = kwargs?
for k, v in kwargs.items():
setattr(self, k, v)
def config_factory(name, config_args... |
a88eb11f659d666ffb7aa2fea30fd5c5d2f603abb8c40ee35eb0010aa8ea53ec | Python | 5,015 | 113 | import os
import shutil
import numpy as np
from scipy.stats import gamma
import hmp
from hmp import simulations
import warnings
import pytest
warnings.filterwarnings("ignore", category=UserWarning)
# Simulation parameters
# Same source everywhere
names = ['bankssts-rh','bankssts-rh','bankssts-rh','bankssts-rh']
n_eve... |
b45b91173b548c666518f8c2d295cda1bceee08c986bbca957f57ee54347caab | Python | 5,015 | 108 | import os
from basicsr.data.data_util import paired_paths_from_folder, paired_paths_from_lmdb
from basicsr.data.transforms import augment, paired_random_crop
from basicsr.utils import FileClient, imfrombytes, img2tensor
from basicsr.utils.registry import DATASET_REGISTRY
from torch.utils import data as data
from torchv... |
98903d285c210f974d52461bcd6073472918868c5b091b106e71f7cd5626a681 | Python | 5,016 | 151 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# 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 applicab... |
82db03c01678517330d7bbd23fcefa646f816c0520a07a4f1d51811435838ed0 | Python | 5,017 | 147 | import sys
import time
import traceback
from math import ceil, log2
from contextlib import contextmanager
import numpy as np
from scipy.sparse import csr_matrix
try:
from mpi4py import MPI
comm = MPI.COMM_WORLD
except ModuleNotFoundError:
MPI = None
comm = None
def is_master(comm=comm):
return co... |
6b6280d146abd5d699897ecfcb556ce8169d4c056ddd918fcc4cac1516aa7df8 | Python | 5,018 | 134 | import matplotlib.pyplot as plt
from gaussian_process import make_gp_funs, rbf_covariance
from scipy.optimize import minimize
import autograd.numpy as np
import autograd.numpy.random as npr
from autograd import value_and_grad
def build_step_function_dataset(D=1, n_data=40, noise_std=0.1):
rs = npr.RandomState(0)... |
7eaa737b764c90a4065bccb9404deea2a4ec900d1daa4e419e5a4a50cca0a81f | Python | 5,018 | 124 | import numpy as np
from scipy.stats import pearsonr
from Functions.f_SignalProcFuncLibs import *
import networkx as nx
def fullFillConnectivity(m_measureEvolution, v_SessionTimes, d_stepSize ):
d_maxBs = int(5 * 60 / 15)
d_maxMt = int(15 * 60 / 15)
d_maxAf = int(5 * 60 / 15) - 1
m_measur... |
f53373bf2e1c224863cb1817950ba5e9cdf58edae76fd7903ad33a2c9f7f44e4 | Python | 5,019 | 118 | # Copyright 2015 The TensorFlow Authors. 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 applica... |
fbe784b2df1db70af24167afb94f24e89234f3af779366d693b1108f264c553e | Python | 5,019 | 88 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
from downward import suites
from lab.reports import Attribute, gm
from common_setup import IssueConfig, IssueExperiment
from relativescatter import RelativeScatterPlotReport
def main(revisions=None):
suite = suites.suite_optimal_with_ipc11()
configs = {
... |
0d3af2c58d5786ca1b6f7475ca8d0bb11ed9d780f2a75a88b2440bec324d7032 | Python | 5,020 | 145 | import numpy as np
import pandas as pd
from scipy.spatial.distance import pdist, cdist, squareform
from scipy.sparse import coo_array
from sklearn.preprocessing import normalize
from sklearn.utils.extmath import safe_sparse_dot
from .utils import printv
DISTS_DTYPE = np.float32
VECT_DTYPE = np.uint16
def calculate... |
60d0481357bb5ef3cf3e4e87a199b94fe0ca1850d22e5c788cd42fe6dc7fd1df | Python | 5,021 | 161 | #
# MIT License
#
# Copyright (c) 2022 GT4SD team
#
# 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,... |
84e23f3d94c0bf0a8ca8c024c312e15d91927526d409361c4d9bc73daa4f1a70 | Python | 5,021 | 131 | """Shared load + downsample + orient helpers for the cellpose GUI previews.
Both the modal "Set Orientation..." dialog and the embedded ``CellposePreviewPanel``
need to read a large stitched section, reduce it to a display size, and apply the
same rotate/flip the detector will apply - so that helper lives here onc... |
90830e604d79468588cf24163d77523fe37340c381e4341c978a60f228e9d90b | Python | 5,021 | 176 | import json
import dash_bootstrap_components as dbc
import dash_renderjson
from dash import Dash, html, State, Output, Input, ClientsideFunction, dcc
def get_navbar():
navbar = dbc.Navbar(
dbc.Container(
[
html.A(
# Use row and col to control vertical align... |
d74aa2e403787912bc0d2d95fed35e9d35061243d2c1b580173418b5795e8a6b | Python | 5,022 | 132 | from scipy.io import savemat
from tvb.simulator.lab import *
import time
import numpy
from matplotlib import pyplot as plt
import multiprocessing as mp
import numpy as np
import os
from tvb.simulator import (simulator, models, coupling, integrators, monitors, noise)
# from tvb.simulator.models import jansen_rit_wendlin... |
6f2d4245cc8254a9804aad3916cfb35e49685fd58d43f6ca9d8e59ed6af4d513 | Python | 5,023 | 145 | """
Generate synthetic test data for unit tests.
Run once to populate regtools/tests/data/ with small synthetic images and files.
"""
import os
import numpy as np
import nibabel as nib
import tifffile
DATA_DIR = os.path.join(os.path.dirname(__file__), "data")
os.makedirs(DATA_DIR, exist_ok=True)
def... |
feb4259c6dd04d712f1607dc9be501d33be2c022a8d34a01a48002fe5137dca5 | Python | 5,023 | 159 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Author:
Maximilia F. S. Degenhardt <frazaodesouzam2@nih.gov>
Hermann F. Degenhardt <degenhardthf@nih.gov>
"""
import os, sys
import pandas as pd
from hornet.uml import filter_data
def get_parameter(filename):
"""
Returns the transformed con... |
f2501a719a2e24d88bf3c640eb1de2631a9786822cfdb108849030887f0e0803 | Python | 5,026 | 138 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# 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 applicab... |
bc7ac3fc180c5662696092f0bea7c27794bfbeedc699dbf9019e49ec24dd1f7c | Python | 5,027 | 150 | import logging
import os
import pathlib
from abc import ABC, abstractmethod
from concurrent.futures import as_completed, ThreadPoolExecutor
from os import PathLike
from threading import RLock
from typing import List, Callable, Union
from tqdm import tqdm
from NDATools import exit_error
logger = logging.getLogger(__n... |
14d6f9273ae3abfc4997279f6fc4f5772698d93b60392db5218f4c11a52bd7b6 | Python | 5,028 | 155 | import os
import os.path as op
import numpy as np
import nibabel as nib
import mne
from mne_gui_addons._ieeg_locate import _CMAP
import matplotlib.pyplot as plt
from params import PLOT_DIR as plot_dir
from params import BIDS_ROOT as bids_root
from params import EXTENSIONS as exts
from params import SUBJECTS as subjec... |
5d7bba8e2e83dfa474a5360eea8e590a601d18bed23c04a7bb90b55187d2a538 | Python | 5,028 | 157 | # set QT_API environment variable
import os
os.environ["QT_API"] = "pyqt5"
import qtpy
# qt libraries
from qtpy.QtCore import *
from qtpy.QtWidgets import *
from qtpy.QtGui import *
import control.utils as utils
from control._def import *
import control.tracking as tracking
from queue import Queue
from threading im... |
8b0f38751861b9be624e65f02ec025b40e92a1f3769933ce684df745136e8203 | Python | 5,029 | 171 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# 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 applicab... |
98069bc9c9fe2fb67ff58d5adff55184b6e4e85bbeb99215bfcac2db6899582b | Python | 5,029 | 161 | import torch
import torch.nn.functional as F
class MathOperations:
def clamp_result(self, result: torch.IntTensor, quant_bits: int) -> torch.IntTensor:
result.clamp_(-(2 ** (quant_bits - 1)), (2 ** (quant_bits - 1)) - 1)
return result
def intadd(
self, a: torch.IntTensor, b: torch.Int... |
cfc60af1a683dbbb527d84cf0507298926dcd489ea8a8322e6a2aafd342f1548 | Python | 5,029 | 165 | import numpy as np
from jitcdde import input as system_input
from ....utils.stimulus import OrnsteinUhlenbeckProcess
from ..builder.base.network import Network, Node
from ..builder.base.neural_mass import NeuralMass
FHN_DEFAULT_PARAMS = {
"alpha": 3.0,
"beta": 4.0,
"gamma": -1.5,
"delta": 0.0,
"ep... |
6a4ce6cfff6bd33a2521b7015ecd22dc5c17b38b9c6e5e0ad00dbcaca4221176 | Python | 5,030 | 105 | import pandas as pd
import numpy as np
import mdtraj as md
import itertools
import os
import MDAnalysis
from MDAnalysis import transformations
def initProteins():
proteins = pd.DataFrame(columns=['pH','ionic','fasta'])
fasta_CPEB4 = """MGDYGFGVLVQSNTGNKSAFPVRFHPHLQPPHHHQNATPSPAAFINNNTAANGSSAGSAWLFP
APATHNIQDEI... |
118a7db9c8fe9c38d80e41c257a324d6f7bc9d43a9b852da5bbe97e74322b363 | Python | 5,032 | 140 | from pathlib import Path
from json import loads, dumps
from typing import Any, Callable, Optional, Union
from .text import Text
from .highlighter import JSONHighlighter, NullHighlighter
class JSON:
"""A renderable which pretty prints JSON.
Args:
json (str): JSON encoded data.
indent (Union[N... |
e42602300c148b4f4679bc5f78162ee437ba306dca67831224a1c52aaad02d23 | Python | 5,032 | 165 | import sys, os
# from models import hcnn
sys.path.append(os.path.abspath(".."))
sys.path.append(os.path.abspath("."))
import torch
import torch.nn as nn
import torch.optim as optim
import prosper_nn.utils.generate_time_series_data as gtsd
import prosper_nn.utils.create_input_ecnn_hcnn as ci
from prosper_nn.models.ecn... |
7b0f4e60440710e8ef1a5d3a66cb97f16dc302f1d6b10287c16031212c86ba0f | Python | 5,033 | 137 | # SPDX-FileCopyrightText: 2015 Eric Larson
#
# SPDX-License-Identifier: Apache-2.0
import types
import functools
import zlib
from pip._vendor.requests.adapters import HTTPAdapter
from .controller import CacheController, PERMANENT_REDIRECT_STATUSES
from .cache import DictCache
from .filewrapper import CallbackFileWra... |
2d68e12bed6dc09367c6e0a8e2c6aa1e79ec21310fb2b622c3d4b5520773f388 | Python | 5,035 | 91 | """
HEMIBRAIN_MB_CONTROL.py - open item N-3, run in hemibrain, no ID map, no login.
Kenyon cells are the ONE population the field already agrees the transmitter
classifier gets wrong: Lin et al. state "we manually corrected the Kenyon cells to be
cholinergic (Methods)". If the effective-sample-size test independentl... |
4fc3b07994de6ce9730e6ba25bd1be14d7983a46ed78e0d5113fb7a106b70ff4 | Python | 5,035 | 166 | import torch
import random
import numpy as np
import pandas as pd
from torch.utils.data import Dataset
from sklearn.metrics import accuracy_score, roc_auc_score, matthews_corrcoef, f1_score, confusion_matrix
# Set a random seed for reproducibility
def set_seed(seed: int) -> None:
np.random.seed(seed)
random.se... |
862031e436ea7c8f6982cdb44e66bc602b709b167a18d4c0dfe4991550b58772 | Python | 5,036 | 168 | """Package to import and export common formats.
"""
from datetime import datetime, timedelta
from json import dump, load
from pathlib import Path
from numpy import c_, empty, float64, nan, memmap
class Wonambi:
"""Class to read the data in Wonambi format, which is fast to write and read
Parameters
------... |
a8e530b3741fe9f67602d2190a67ae6ea05f71b96ed32724d07c7bc0c546ac03 | Python | 5,036 | 149 | import numpy as np
from collections import deque
import asyncio
from typing import Deque
from scipy.signal import find_peaks
from ._messages import FloatMessage
import labgraph as lg
class QRSDetectorState(lg.State):
xs: Deque[float] = None
samples_since_qrs: int = 0
qrs_peak_value: float = .0
noise_... |
e17808cd06ea766c42bba8f0e6bbca13ec2f6f3e3495dd32035478b73c61afd2 | Python | 5,037 | 119 | """Write ISMRMRD file for imaging data."""
from importlib.metadata import version
from pathlib import Path
import ismrmrd
import numpy as np
from pypulseq.Sequence.sequence import Sequence
from console.interfaces.dimensions import Dimensions
from console.interfaces.rx_data import RxData
from console.utilities.data im... |
2e0b65ba389ae594896dd53a0fc79f94c3a4e695206f7bd0a9ee80142302d26f | Python | 5,038 | 155 | """
Script for inserting GraphMCF properties from a scalar field
Input: - GraphMCF instance (pkl)
- Scalar field (tomogram)
Output: - GraphMCF with the props added
"""
__author__ = 'Antonio Martinez-Sanchez'
# ################ Package import
import sys
import time
import getopt
from glo... |
b60b50d8cc51fb5b368271247ac3b47099bda13d433e0439ad1096d738d02ba7 | Python | 5,038 | 118 | from typing import Optional
import numpy as np
import torch
import torch.nn
from . import ArrayOrTensor, OptionalArrayOrTensor
from .base import BaseModel
class Independent(BaseModel):
def __init__(self, n: int, factors: OptionalArrayOrTensor = None, normalize: bool = False, device: str = 'gpu',
... |
fa36c7fe13a643dc0d51b16539d92f40a3a065c74a364a793bcec35dff19af3a | Python | 5,038 | 148 | """This Bayesian optimization demo using gradient-based optimization
to find the next query point."""
import matplotlib.pyplot as plt
from gaussian_process import make_gp_funs, rbf_covariance
from scipy.optimize import minimize
import autograd.numpy as np
import autograd.numpy.random as npr
from autograd import value... |
04217761314e8ba82b6b321f68069ad493ff9bbd0295c3512481660bf2f11dc4 | Python | 5,039 | 145 | import numpy as np
from elasticai.creator.file_generation.savable import Path
from elasticai.creator.file_generation.template import (
InProjectTemplate,
module_to_package,
)
from elasticai.creator.nn.integer.ram.design import Ram
from elasticai.creator.vhdl.auto_wire_protocols.port_definitions import create_p... |
3f14701f0f1df18fdaf3bba6c2f8eb1879b6af41ce63a6142a4513dd30b08abe | Python | 5,039 | 121 | import torch
from torch import nn
from torchdrug import core, layers
from torchdrug.layers import functional
from torchdrug.core import Registry as R
@R.register("models.GraphAF")
class GraphAutoregressiveFlow(nn.Module, core.Configurable):
"""
Graph autoregressive flow proposed in `GraphAF: a Flow-based Aut... |
518938bbe4f4826e20e2bd5a8a8fa64fb088f790c5dd6ab408d2df5f54076400 | Python | 5,040 | 131 | import numpy as np
from sklearn.feature_selection import RFECV
from sklearn.linear_model import LogisticRegression
from sklearn.ensemble import RandomForestClassifier
from sklearn.svm import SVR
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
import pandas as pd
#... |
6c216ca377a3266bb8285aa88e966c1f2420b07d23490d259744547b4a310dbc | Python | 5,040 | 159 | """
Script for inserting template matching results (scores y angles) in a GraphMCF
Input: - GraphMCF
- Template matching output (Pytom)
- Refinement parameters
Output: - Graph with template matching information inserted as vertex and edge properties
"""
__author__ = 'Antonio Ma... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.