sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
801384291294b71795630db3dba4e5457dadba7954a222c118686881fb464093 | Python | 1,522 | 59 | '''
Adapted from DeeperCut by Eldar Insafutdinov
https://github.com/eldar/pose-tensorflow
'''
import pprint
import logging
import yaml
from easydict import EasyDict as edict
from . import default_config
cfg = default_config.cfg
def _merge_a_into_b(a, b):
"""Merge config dictionary a into config dictionary b, ... |
b8262d39a61e6c99eaf79e6dc8c5eafd04184af75180d2d8d04c6a61e23d66f1 | Python | 1,522 | 65 | import pickle
import contextlib
import joblib
from joblib import Parallel, delayed
import json
from tqdm import tqdm
import torch
import numpy as np
latent = 64
conv_len = 32
emb_len = 12
fea_len = 0
half_length = 500
length = 2 * half_length + 1
max_t = 32
# NANO_MODE = 'm6anet'
NANO_MODE = 'sramp'
@contextlib.cont... |
c094cd39b1505303ea2a1a1f06a505ce04b327ae30dd7edc663b2a6b5431219f | Python | 1,523 | 36 | import sys
import gzip
dfh1=gzip.open(sys.argv[1],'r')
dfh2=gzip.open(sys.argv[1].replace('R1','R2'),'r')
rfh1=open(sys.argv[1].split('/')[-1]+'_trimmed.fastq','w')
rfh2=open(sys.argv[1].split('/')[-1].replace('R1','R2')+'_trimmed.fastq','w')
F_trim=int(sys.argv[2])
B_trim=int(sys.argv[3])
line1_1=dfh1.readline()
line1... |
ea08d283248e1de2d2dd4b56276a6d97747fda2fa1d92cb39617902239a69f0f | Python | 1,523 | 44 | import os
import shutil
import numpy as np
import os.path as op
import nibabel as nib
from glob import glob
from scanphyslog2bids.core import PhilipsPhysioLog
def test_python_interface():
here = op.dirname(__file__)
data_dir = op.join(here, 'data')
logs = [
(op.join(data_dir, 'example_for_gradient... |
137324932a9316b476e37bf064f50f7ecbb1221150ffae165918f16dab440778 | Python | 1,524 | 31 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany
#
# 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
#
# ht... |
488bffdf4aebdd32417fcdd93e9c5c51349e12ecc28eb7a1ea992f0c1b94f3cc | Python | 1,524 | 31 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany
#
# 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
#
# ht... |
817f308ab39ecb4b170d74062ae9d3c3db953fe6045341ea6185f9c917112ef8 | Python | 1,524 | 31 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany
#
# 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
#
# ht... |
85dbdcdb7271f42088a3f80dd0440121c7bd60a347cf5ddd080f1bbc4cb99bf8 | Python | 1,524 | 37 | import torch
import torch.nn as nn
import model.RNN.model as rnn
import model.GCN.model as gcn
from lib import utils
class HighResNet(nn.Module):
"""Some Information about HighResNet"""
def __init__(self, in_feat, hid_feat, num_RU, A, gcn_order=2, out_feat=1, dropout=0.0, **kwargs):
super(HighResNe... |
be4b576e31b20fb50284043ddc33c93395b979a9a5f00e66a069bccbb32e3544 | Python | 1,524 | 56 | import time
import asyncio
class Rate(object):
"""
Convenience class for sleeping in a loop at a specified rate
"""
def __init__(self, hz: float):
"""
Constructor.
@param hz: hz rate to determine sleeping
@type hz: float
"""
self.last_time = time.time()
... |
c340783af5d7d7c6db6e187895dfa51c86a1940fa4e7092e8bcf22aa714d1981 | Python | 1,524 | 57 | import ntpath
import os
import warnings
from src import utils
from src.gan_settings import GanSettings
from src.methods import Methods
warnings.filterwarnings("ignore")
def load_models(method):
settings = GanSettings()
cell_type = settings.type
if method==Methods.METHOD_GAN_IMG_PROC.value and cell_type=='rh... |
2417f8c971ee58deebc915a452e7f65cf3a6f2d4e18258f71f37a61dac4f6480 | Python | 1,525 | 53 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
from lab.environments import LocalEnvironment, MaiaEnvironment
import common_setup
from common_setup import IssueConfig, IssueExperiment
DIR = os.path.dirname(os.path.abspath(__file__))
BENCHMARKS_DIR = os.environ["DOWNWARD_BENCHMARKS"]
REVISIONS = ["issue68... |
4599f42c7e43c59bb765f2ec4e7a2a80c0e87563556e452bfa6d6cb6f5cd9984 | Python | 1,525 | 47 | import numpy as np
import pytest
from regtools.geometry_registration import ccf_bridge
from regtools.geometry_registration.types import RunParams
def test_runparams_annotation_image_default():
assert RunParams(tiff_path="x", ccf_index=0).annotation_image_path is None
def test_as_label_slice_2d():
... |
8d183fdad2d2a9897abe321959b7aed6d8100edf294894e8b6c26e3cf0dba1af | Python | 1,525 | 53 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
from lab.environments import LocalEnvironment, MaiaEnvironment
import common_setup
from common_setup import IssueConfig, IssueExperiment
DIR = os.path.dirname(os.path.abspath(__file__))
BENCHMARKS_DIR = os.environ["DOWNWARD_BENCHMARKS"]
REVISIONS = ["issue68... |
bb88ab4e23c9c891022ab31476905a2e4ea6c41b8338d2394eb039d53a874e41 | Python | 1,525 | 50 | import math
from collections.abc import Sequence
import torch
from torch import nn
class IndependentGaussian(nn.Module):
"""
Independent Gaussian distribution.
Parameters:
mu (Tensor): mean of shape :math:`(N,)`
sigma2 (Tensor): variance of shape :math:`(N,)`
learnable (bool, opt... |
e482b7bd56c9ef6bb08e324b9c79e55b51e7bd5fe715b4c65d5bb289486c69f7 | Python | 1,525 | 52 | import torch
from torch import nn
from torch.nn import functional as F
class FocalLoss(nn.Module):
"""
Focal loss.
Args:
gamma: Exponent of the modulating factor (1 - p_t) to
balance easy vs hard examples.
reduction: 'none' | 'mean' | 'sum'
'none': No reduction ... |
5647ee58397755686ea079e72fe31af9740a36408adfb7616d63f19c7f63d079 | Python | 1,526 | 47 | #!/usr/bin/env python
from __future__ import print_function
import argparse
import os
from pybullet_tools.pr2_problems import create_floor
from pybullet_tools.utils import connect, disconnect, wait_for_user, LockRenderer, stable_z, \
load_model, ROOMBA_URDF, \
HideOutput, set_point, Point, load_pybullet, get... |
29a5835de15296ae0b1ca6e22af540d8f22094e6afd8a7dfd24d857c8b89311a | Python | 1,527 | 32 | from typing import Dict
from model.NextXVisit import BertForMultiLabelPrediction
from pytorch_pretrained_bert import BertConfig
#################################
# Models for federated learning #
#################################
class CustomBertConfig(BertConfig):
def __init__(self, config):
super(Custo... |
2e71e76de7dd69eba565156679640657075597fd2e2e3fb57801dba7183120b8 | Python | 1,527 | 54 | from __future__ import annotations
from subprocess import CalledProcessError
import pytest
from quacc import change_settings
from quacc.runners.generic import GenericRunner
def test_generic_runner(tmp_path, monkeypatch):
"""Test the `GenericRunner` class with a simple command."""
gr = GenericRunner(command... |
8184e13639ad2c9de5e839a2a86e622bef23b9a66145529d12d7ab5d8befdc14 | Python | 1,527 | 45 | from __future__ import absolute_import, division, print_function
import os.path as op
# Format expected by setup.py and doc/source/conf.py: string of form "X.Y.Z"
_version_major = 0
_version_minor = 1
_version_micro = '' # use '' for first of series, number for 1 and above
# _version_extra = 'dev'
_version_extra = ''... |
5ed06e658e32626af9d04d80fdf0338d6866d08930695c3136c35560313b9ecc | Python | 1,528 | 48 | # -*- coding: utf-8 -*-
# Copyright (c) 2012 Giorgos Verigakis <verigak@gmail.com>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS P... |
95ee625d1bc7554e2d0615b387c2e501ed90b02c70a712f8dd7d71f04d652467 | Python | 1,528 | 46 | #!/usr/bin/env python
from __future__ import print_function
import argparse
import os
from examples.pybullet.utils.pybullet_tools.pr2_problems import create_floor
from examples.pybullet.utils.pybullet_tools.utils import connect, disconnect, wait_for_user, LockRenderer, stable_z, \
load_model, ROOMBA_URDF, \
... |
d0dd01bd5b660b2925abead7a4fd9212361492cbb04904cc19da7ae375e1591c | Python | 1,528 | 48 | extensions = dict(
required_params=['training_frame', 'x'],
validate_required_params="",
set_required_params="""
parms$training_frame <- training_frame
if(!missing(x))
parms$ignored_columns <- .verify_datacols(training_frame, x)$cols_ignore
""",
)
doc = dict(
preamble="""
Trains an Extended Isolation... |
d43719b1ba505b0d0eb99f176b415320b34dedc278f8635507033e1f29c3c22b | Python | 1,528 | 56 | from elasticai.creator import ir as _ir
from . import _ir as _lf_ir
from ._ir import pattern_rule, sequential_with_interface
def _constraint(
pattern_node: _lf_ir.Node,
graph_node: _lf_ir.Node,
/,
) -> bool:
match pattern_node.name:
case "start":
return graph_node.type in ("filter... |
f1cf1fb535d47397f9c6c1c47a39004ff7650c034c46ba1edba0bc6bc6e5b2d9 | Python | 1,528 | 129 | STOP_WORDS = {
"i",
"me",
"my",
"myself",
"we",
"our",
"ours",
"ourselves",
"you",
"your",
"yours",
"yourself",
"yourselves",
"he",
"him",
"his",
"himself",
"she",
"her",
"hers",
"herself",
"it",
"its",
"itself",
"they",... |
50d062c20e2cef553ec71ed7315feddccdddc9e85993ed4c9538487eccefa17d | Python | 1,529 | 56 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
from downward import suites
from downward.reports.scatter import ScatterPlotReport
import common_setup
from relativescatter import RelativeScatterPlotReport
SEARCH_REVS = ["issue547-base", "issue547-v2"]
SUITE = suites.suite_satisficing_with_ipc11()
CONFIGS = {
'a... |
daffb5fa923a67fbf9a6232bf5d5e3e91dceae4be1c796f38b9c0eaac61be4ea | Python | 1,529 | 49 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 20 16:24:42 2023
@author: emma
1. loads the original model trained for disease classification and splits it into the encoder + disease head
2. loads the model from bias pre-training and saves only the head
"""
SEED=1
import os
os.environ['TF_DETER... |
870a352dede0165b4fe1e7a78897bbd4bbba0517325cd6701b03f23265d613ee | Python | 1,532 | 32 | """only modified by brains"""
from tokenize import group
import os.path as path
import numpy as np
from eworm.utils import *
from eworm.network import *
from eworm.network.process import *
import pickle
import time
if __name__ == "__main__":
np.random.seed(42)
group_name = "video_offline"
config_dir = pat... |
88e25dba3faa91e72d18869f05d5e103a80c03ee5d51f92e1892a3c9de8365cc | Python | 1,532 | 48 | from psychopy import prefs
prefs.hardware['audioLib'] = ['PTB']
from psychopy import gui, visual, event, core
from os import system, path, chdir
from random import shuffle
my_path = path.abspath(path.dirname(__file__))
chdir(my_path)
def quit():
win0.close()
core.quit()
event.globalKeys.add(key='escape', fun... |
94b8c2649cd0bed2ec0e87b90281b62a84f13d2d81059fe619908364c685c613 | Python | 1,532 | 41 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
from downward import suites
import common_setup
REVS = ["issue392-v2"]
LIMITS = {"search_time": 300}
CONFIGS = {}
for randomize in ["false", "true"]:
for pref_first in ["false", "true"]:
CONFIGS["lama-unit-randomize-%(randomize)s-pref_first-%(pref_first)s"... |
04591d20d25ed9879da07bfeba64e05490e3dede9baee77f6258ac7fe8895dbd | Python | 1,533 | 55 | from __future__ import annotations
import pytest
redun = pytest.importorskip("redun")
from ase.build import bulk
@pytest.fixture()
def scheduler():
return redun.Scheduler()
from quacc import flow, job
from quacc.recipes.emt.core import relax_job
from quacc.recipes.emt.slabs import bulk_to_slabs_flow # skipcq... |
aa1a719654952a357df91bb0259f96599c5e0fb85f668265722c9b1f8a91e5b8 | Python | 1,533 | 48 | from psychopy import prefs
prefs.hardware['audioLib'] = ['PTB']
from psychopy import gui, visual, event, core
from os import system, path, chdir
from random import shuffle
my_path = path.abspath(path.dirname(__file__))
chdir(my_path)
def quit():
win0.close()
core.quit()
event.globalKeys.add(key='escape', fun... |
a401f5a287d97fba7c9064973cb3b0f2e9fa378868bf298364814edcb0e40a23 | Python | 1,534 | 39 | #----Figure_04_preparation------------------------------------------------------
#-------------------------------------------------------------------------------
# This is the code which has to be run in preparation for Figure 04
# for the connectivity analysis for Reinhard and Fukuda et al. 2024
#-----------------... |
042d067daa62ded1e02da1c062973aabb1e18a563fddc0e71ab6eaffbf0cb3a0 | Python | 1,535 | 53 | from cloudvolume import CloudVolume
import numpy as np
import pandas as pd
# key slices @ mip=0
film01 = (slice(218500, 219524), slice(54000, 55024))
film02 = (slice(213400, 214424), slice(78200, 79224))
film03 = (slice(216400, 217424), slice(105600, 106624))
film04 = (slice(217700, 218724), slice(59900, 60924))
resi... |
4edcb8e5f3a31f8d1f0a89531a4a8a42f41099b62c32993e9c2c9f2dcbf6bc6e | Python | 1,535 | 65 | # SPDX-FileCopyrightText: 2015 Eric Larson
#
# SPDX-License-Identifier: Apache-2.0
"""
The cache object API for implementing caches. The default is a thread
safe in-memory dictionary.
"""
from threading import Lock
class BaseCache(object):
def get(self, key):
raise NotImplementedError()
def set(sel... |
5f58ee413012140d7c1af5887ca6ee5776fc36c047bff094b22116deaa6c6171 | Python | 1,535 | 74 | import time
import os
import sys
class POCVoxelEnv():
data_test = './data/poc/voxel/test'
data_train = './data/poc/voxel/train'
shape_checkpoint = '<<The 2D UNet model checkpoint>>' # put the 2D model checkpoint here.
class POCShapeEnv():
data_test = './data/poc/shape/test'
data_train = './data/po... |
66a96e3b224ec184c1ff035bf4c906fe3e60576bf4fba59959f2b6183d628174 | Python | 1,535 | 33 | import pandas as pd
from typing import Tuple
import torch
from torch.utils.data import DataLoader, WeightedRandomSampler
from src.dataloaders.rocf_dataset import ROCFDataset
def get_dataloader(labels: pd.DataFrame,
label_type: str,
batch_size: int,
image_size... |
57899f6ac80829dbb09da24fc8e7ac1bac8f529bc890c4e5e1a83b325ab195fe | Python | 1,536 | 31 | from pathlib import Path
from wsilearn.utils.flexparse import FlexArgumentParser
from wsilearn.utils.cool_utils import read_json_dict, write_json_dict
from wsilearn.train_nic import NicLearner
def eval_nic(model_dir, data_config, preprocess_dir, out_dir, no_heatmaps=False, no_out=False, cache_dir=None, **kwargs):
... |
7dd2486c2f2e2e3c505b4650d5e18d593625ddcc88bda0209a74619cb591f242 | Python | 1,536 | 66 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@author: emma
"""
import SimpleITK as sitk
import glob
import random
random.seed(6)
import argparse
def generate_avg_map(fpaths, bias_label):
for i, fpath in enumerate(fpaths):
print('reading image: {}'.format(i))
img = sitk.ReadImage(fpath)
... |
0017768f8a00c9f34d7d5f336b9fac5c495fb92a99cf5ff4503731ea9aa5c023 | Python | 1,537 | 55 | import construct #To parse the meshes
import requests
def getSegmentMesh(segmentation_volume, chunk_x, chunk_y, chunk_z, segment_id):
""" Segments mesh comes with coordinates from [0.0 1.0] for a given tasks.
A tasks contains 8 chunks, which is selected by specifying chunk_x, chunk_y, chunk_z.
coordinates for... |
1f8644668797062b4b72b5bfce23f4bf78984e8e0a9232b35ecbff5f7cec258d | Python | 1,537 | 41 | #
# 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,... |
afad0bb2d198aae8ebd2d46dd7f5c160b06ddc0e6b55e08f14da73c3f2381cab | Python | 1,537 | 39 | """
toposampling - Topology-assisted sampling and analysis of activity data
Copyright (C) 2020 Blue Brain Project / EPFL & University of Aberdeen
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as
published by the Free Software Found... |
e58ef0d7b0127c530ab44da4f1828bd7337210277c23dcbb3eba23048943f507 | Python | 1,537 | 44 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2024 Clinic for Diagnositic and Interventional Radiology, University Hospital Bonn, Germany
#
# 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 ... |
e8d9cc5fc1ea175e48775556a182a0486ec26b8582996d9068be415525fd2a1e | Python | 1,537 | 49 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
from lab.environments import LocalEnvironment, MaiaEnvironment
import common_setup
from common_setup import IssueConfig, IssueExperiment
from relativescatter import RelativeScatterPlotReport
DIR = os.path.dirname(os.path.abspath(__file__))
BENCHMARKS_DIR = o... |
ebaef1217fbd04694d6192f33a96bac32b4ce5222fd522ee607e7cdc11e8b355 | Python | 1,537 | 49 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
from lab.environments import LocalEnvironment, MaiaEnvironment
import common_setup
from common_setup import IssueConfig, IssueExperiment
from relativescatter import RelativeScatterPlotReport
DIR = os.path.dirname(os.path.abspath(__file__))
BENCHMARKS_DIR = o... |
0674da78d2d71b019cd36a62831cc6b90f821e3d37cf03fea85134a53f93fcbc | Python | 1,538 | 29 | # Copyright (c) 2020, Ko Sugawara
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and t... |
16c8c760f4e21e142edb2ca727af9d0890b7bf5ff2e67f697cd16befaf744f70 | Python | 1,538 | 46 | import torch
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
class MeanAct(nn.Module):
def __init__(self):
super(MeanAct, self).__init__()
def forward(self, x):
return torch.clamp(torch.exp(x), min=1e-5, max=1e6)
class DispAct(nn.Module):
def __init__(self):
... |
772d3fdb50591de47752edbf6438d30be9eb1c72d52fd2b9b0bf72ba17f4351a | Python | 1,538 | 52 | import jax.numpy as jnp
import jax.numpy as jnp
from src.utils import get_full_distance_matrix
REG_EPS = 1e-12
def coulomb_potential(dist_mat, charges=None, smooth=None):
if smooth is None:
denom_mat = dist_mat + REG_EPS
else:
denom_mat = jnp.sqrt(dist_mat**2 + smooth**2)
if charges is No... |
0b75ada6fe08c24e53507d33cc2f376e89fb714d6651f3365e18c8e48b2509b9 | Python | 1,539 | 35 | ###############################################################################################
# Emma Bailey, 17/06/2024
###############################################################################################
import numpy as np
from Functions.import_data_rs import import_data
if __name__ == '__main__':
s... |
706ebfda85e8d3eb7fb3d1e181801a14e62633398eb1a3ea642fbdeca9972b9d | Python | 1,540 | 65 | from __future__ import annotations
import pytest
jf = pytest.importorskip("jobflow")
from quacc import flow, job, subflow
def test_jobflow_decorators(tmp_path, monkeypatch):
monkeypatch.chdir(tmp_path)
@job
def add(a, b):
return a + b
@job
def mult(a, b):
return a * b
@su... |
7605d7dd6093ad22bd23f0a33c0a2f629f097f429f54450af7049522948321cc | Python | 1,540 | 47 | # 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... |
7fbcaad991e9229106ed269de0c23264663e20d8eaef6258e92de929feba40ee | Python | 1,541 | 42 | """
This script computes the mean framewise displacement. In this case, remember
that the MRI tasks usually had a washout at the beginning and at the end. Since
we are not interested in those segments and they will not be included in the
adjacency matrix computations, we also need to compute the mean FD for the
inc... |
a66f2adae9f83184a7388821da6f3649c65919709c0db7991373a6b73648ece0 | Python | 1,541 | 36 | """
Main run function for finding cell assemblies in spiking data
last modified: András Ecker 10.2022
"""
import logging
from assemblyfire.utils import ensure_dir, get_nrn_df
from assemblyfire.spikes import SpikeMatrixGroup
from assemblyfire.clustering import cluster_spikes, detect_assemblies
L = logging.getLogger("... |
e22cddc4a41afee43a1c17948aab902c6f049079911aea6c6179f99c46e44e29 | Python | 1,541 | 54 | import numpy as np
def t_score(X, y):
"""
This function calculates t_score for each feature, where t_score is only used for binary problem
t_score = |mean1-mean2|/sqrt(((std1^2)/n1)+((std2^2)/n2)))
Input
-----
X: {numpy array}, shape (n_samples, n_features)
input data
y: {numpy ar... |
5ab1e52dd819d621e161705545860447f564295d035a5994ce67341822f8723f | Python | 1,542 | 58 | import warnings
from contextlib import contextmanager
import pytest
import autograd.numpy as np
from autograd import deriv, grad
from autograd.core import primitive_vjps
from autograd.extend import primitive
from autograd.test_util import check_grads
def test_assert():
# from https://github.com/HIPS/autograd/is... |
7260bd9ccef100182b3e77074432ec97cf0f71dfa840d7141c06ba7a269c4804 | Python | 1,542 | 67 | import torch.nn as nn
from . import base
from . import functional as F
from ..base.modules import Activation
class JaccardLoss(base.Loss):
def __init__(self, eps=1.0, activation=None, ignore_channels=None, **kwargs):
super().__init__(**kwargs)
self.eps = eps
self.activation = Activation(a... |
79f3b1b74d94878d0710f8062f1003ea7348cee5b2f830e6dc1ed5f2a60861fd | Python | 1,542 | 42 | import os
import unittest
from hed import load_schema, load_schema_version
from hed.schema import HedSchemaGroup
from hed.schema.schema_io import schema_util
class Test(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.default_test_url = (
"""https://raw.githubusercontent.com/hed-... |
2bf4abb84e4d60f230570168d1b678a4143ee45290da307d7d0670acd17e9cde | Python | 1,543 | 39 | from cirrocumulus.anndata_util import X_stats, obs_stats
class FeatureAggregator:
def __init__(self, obs_measures=[], var_measures=[], dimensions=[]):
self.obs_measures = obs_measures
self.var_measures = var_measures
self.dimensions = dimensions
@staticmethod
def add_to_result(df,... |
7a63195a1ddccc810b5ba1f88e3c919e56669504b71af9eb3bdcf6ecbb1eccff | Python | 1,546 | 64 | """Core recipes for MRCC."""
from __future__ import annotations
from typing import TYPE_CHECKING
from quacc import job
from quacc.recipes.mrcc._base import run_and_summarize
if TYPE_CHECKING:
from typing import Any
from ase.atoms import Atoms
from quacc.types import CopyFiles, RunSchema
@job
def sta... |
a10ad04c4f27f4e27e95b8ad02e039750fb7cf3f0c44e6afbbf7659ad4146398 | Python | 1,546 | 32 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany
#
# 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
#
# ht... |
b70dde6830648ad0e2f7b67f6de44600ce4f4a8ffb33895871eaa68da651194e | Python | 1,546 | 54 | def update_param(name, param):
if name == 'stopping_metric':
param['values'] = ['AUTO', 'AUUC', 'ATE', 'ATT', 'ATC', 'qini']
return param
if name == 'distribution':
param['values'] = ['AUTO', 'bernoulli']
return param
return None # param untouched
extensions = dict(
ex... |
9bb5757d5032d4ef22bc5bd63d64bdd19aba8573c79357b70d65fbb9f7137e6f | Python | 1,547 | 46 | """Registration GUI package - split from the monolithic gui.py for maintainability.
Submodules
----------
dialogs
Preview2DDialog, RegistrationResultDialog, ManualSetupDialog
registration_tab
RegistrationTab (main workflow tab) and _load_image_volume helper
parameters_tab
ParametersTab (advanced p... |
c0b8eacb66ec21467dad68652b6a311d0b52b1cd022df858f4531b6e41c9020e | Python | 1,547 | 41 | #
# MIT License
#
# Copyright (c) 2024 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,... |
96d4cfabdcd2c2f3007a9f1a459b60dace045bae5da4c639e7f3eef85e63ad73 | Python | 1,548 | 49 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
from downward import suites
import common_setup
REVS = ["issue527-v1"]
SUITE = suites.suite_optimal_with_ipc11()
CONFIGS = {
"astar_occ_lmcut": [
"--search",
"astar(operatorcounting([lmcut_constraints()]))"],
"astar_occ_seq": [
"--search... |
c15f1b18c4d71782d655c05f4319e348a00324808b2d82054084c284e16d0c15 | Python | 1,548 | 41 | """Concatenate evaluation result files into a single data table."""
import argparse
import os
import sys
# Allow imports from the parent workflow package (e.g., workflow/utils).
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from utils import load_files, to_numeric # noqa: E402
# --- Parse inputs ... |
2598e0d5ab7d1e6c963a689fe0e0bd13eecad49f20d49f931581cc53ce70bed0 | Python | 1,549 | 39 | #! /usr/bin/env python3
import os
import tarfile
import urllib.request as urllib
def download_and_extract(url,script_dir,wt_dir,wt_file,wt_file_gz,name=''):
if os.path.exists(wt_file):
return
print('Downloading %s pretrained weights..'%name)
if not os.path.exists(wt_dir):
os.makedirs(wt_... |
42bd619575993f7d99b263b1aa1d33139d0ce3241ddae00e075469a1b597047c | Python | 1,549 | 37 | import os
from typing import Iterable
import bpy
from nodebpy.builder.asset import AssetNodeGroup
def link_asset_groups(groups: Iterable[type]) -> None:
"""
Link the node groups of several asset classes, reading each asset library once.
Each asset group otherwise reads its whole library when it is first ... |
a90f61fa08f1ee703e42b9bda2c66c483fb99066c00cd851dc70c2fb8bd478b3 | Python | 1,549 | 66 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from setuptools import setup, Extension
from Cython.Distutils import build_ext
import glob as gg
import numpy as np
import os
import sys
with open('README.rst') as readme_file:
readme = readme_file.read()
with open('HISTORY.rst') as history_file:
history = history_f... |
1f186d55ebb8f7776cd7c1a4c290998938d28b551f44b6641a8dd310918b1a3a | Python | 1,550 | 52 | """Derive positive/negative labels from segmentation masks.
python -m src.make_labels --data-dir data
"""
import argparse
import csv
from pathlib import Path
import numpy as np
from PIL import Image
from scipy import ndimage
STRUCT = np.ones((3, 3), int) # 8-connectivity, matching bwconncomp(img, 8)
def count... |
bc8a914d4886803280ca7bcbb4e20512e9057ae06d841f0259e13e053eaf6f48 | Python | 1,550 | 51 | import torch
import torch.nn as nn
import torch.nn.functional as F
#from torch import Generator
from typing import Any
#from collections import OrderedDict
from ..prixfixe import CoreBlock
from .add_blocks import ConformerSASwiGLULayer
#from .utils import initialize_weights
class UnlockDNACoreBlock(CoreBlock):
... |
d3af758293bbb5df6c85d12d27b4f468d786466496334ac0005b441818dafedf | Python | 1,550 | 54 | import setuptools
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
setuptools.setup(
name="PyReliMRI",
version="2.2.3",
description="A package for computing reliability of MRI/fMRI images",
long_description=long_description,
long_description_content_type="text/... |
b7a29195f2615862ca8f5dcaa478f4d0d063d7c0ee01db4fb0a824d9c9ec929b | Python | 1,551 | 47 | #!/usr/bin/env python
# coding: utf-8
# Copyright (C) 2021 Blue Brain Project, EPFL
#
# 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 Software Foundation, either version 3 of the License, or
# (at your option) any... |
0ba2d8c031528acf6d05c7ccdb627879fd5448bad25f578a1db41262aaf7382a | Python | 1,552 | 52 | # -*- coding: utf-8 -*-
import numpy as np
import tensorflow as tf
import yolo_v4
import yolo_v4_tiny
from PIL import Image, ImageDraw
from utils import load_weights, load_coco_names, detections_boxes, freeze_graph
FLAGS = tf.app.flags.FLAGS
tf.app.flags.DEFINE_string(
'class_names', 'coco.names', 'File with cl... |
8649446ba4a7651fbcefafbb84e19ee13ead59c3a1f7a39b11f53be57d41c5ee | Python | 1,552 | 40 | #----Figure_01_E_F_preparation--------------------------------------------------
#-------------------------------------------------------------------------------
# This is the code which has to be run in preparation for Figure 01 Panel E and F
# for the connectivity analysis for Reinhard and Fukuda et al. 2024
#---... |
df6a5a0143d27908323caae029fb256a6bd4d2697a0d8643c5804a9caf18c8eb | Python | 1,552 | 41 | import torch
import os
import detectron2
from detectron2 import model_zoo
from detectron2.engine import DefaultPredictor
from detectron2.config import get_cfg
from detectron2.modeling import build_model
from detectron2.checkpoint import DetectionCheckpointer
import detectron2.data.transforms as T
#import numpy as np
d... |
085ae7095138bd04e1ea839baefd0f97de244f0b669f02bde0f45313bdfb75a1 | Python | 1,553 | 46 | import torch
from torch.nn.modules.loss import _Loss
class MCCLoss(_Loss):
def __init__(self, eps: float = 1e-5):
"""Compute Matthews Correlation Coefficient Loss for image segmentation task.
It only supports binary mode.
Args:
eps (float): Small epsilon to handle situations w... |
4c477df4b9af4572552251293d0a36b466692f0c21d759957003dc508d10e0a5 | Python | 1,553 | 50 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
from lab.environments import LocalEnvironment, BaselSlurmEnvironment
import common_setup
from common_setup import IssueConfig, IssueExperiment
from relativescatter import RelativeScatterPlotReport
DIR = os.path.dirname(os.path.abspath(__file__))
BENCHMARKS_D... |
50b14a442dcd69dd5655b2da7838d42ac7ea6118b57101a4fdad796a28419360 | Python | 1,554 | 41 | """Tests for the 'Don't know' moving-pitch estimate helper."""
import os
from regtools.registration.registration_2d import (
_read_2d_shape,
estimate_moving_pitch_um,
)
_DATA = os.path.join(os.path.dirname(__file__), "data")
_SINGLE_TIF = os.path.join(_DATA, "tiff_sections", "section_000_1_0.tif")
... |
6a1f6b03270c80b2a4a564762604dfc6d04d8b45b1ef987787f6eb487625dc61 | Python | 1,554 | 41 | #!/usr/bin/env python
from __future__ import print_function, division
import os
import sys
from topaz.metrics import particle_prc
here = os.path.abspath(__file__)
root = os.path.dirname(os.path.dirname(here))
sys.path.insert(0, root)
import numpy as np
import pandas as pd
import argparse
name = 'precision_recall_c... |
2d88e8ddba672a73068dda53307db240f8da641c97e34a4a97c2deaf3d8487f5 | Python | 1,555 | 65 | from __future__ import annotations
from dataclasses import dataclass, field
@dataclass
class CategoryConfig:
"""
Configuration for the Experimental Category stage.
category_fields:
Metadata columns that MorphoGlia combines to create the
reserved 'category' column.
Example:
... |
5da4a929fc8142ff60a2d26ca86cce55b112517bf4c0fa948289d1a076a887ff | Python | 1,555 | 61 | # external
import pytest
# project
import textdistance
ALG = textdistance.Editex
@pytest.mark.parametrize('left, right, expected', [
# https://github.com/chrislit/abydos/blob/master/tests/distance/test_distance_editex.py
('', '', 0),
('nelson', '', len('nelson') * 2),
('', 'neilsen', len('neilsen')... |
6477868db29ad707165e97849fd3bd3b8b447a17b2165d480f63a218ce5892f5 | Python | 1,555 | 39 | from __future__ import division, print_function
import argparse
import numpy as np
from topaz.utils.picks import create_particle_stack
name = 'particle_stack'
help = 'extract mrc particle stack given coordinates table'
def add_arguments(parser=None):
if parser is None:
parser = argparse.ArgumentParser(... |
5acbea9cd09a7cf73f27b1d77315555940ed363f6bcc9704cea2bec3396e0fc1 | Python | 1,556 | 55 | # -*- coding: utf-8 -*-
# @Author: Sadamori Kojaku
# @Date: 2023-06-08 16:38:19
# @Last Modified by: Sadamori Kojaku
# @Last Modified time: 2023-06-15 12:04:07
import unittest
import networkx as nx
import numpy as np
from scipy import sparse
import embcom
class TestEmbedding(unittest.TestCase):
def setUp(self... |
687e94ca94f013bb357145d702432f3680f35490a83f424799933ef324a85850 | Python | 1,557 | 30 | #!/usr/bin/env python3.9
# evaluate a hypothetical model where our prediction is the kit provided "on target information"
from ownutil import ParseArgs, PrepareData
# read command line arguments (data set, epoch number, train/validation size)
args = ParseArgs()
#model specific wired setup
args.modelnum = 11 # m... |
8a790e21ea108fe9262e518e064e9375bb35a584289d95d902ae8ffdaf0121bb | Python | 1,557 | 60 | # pylint: disable=too-many-function-args, invalid-name, unused-argument
""" HCP ROI dataset loading script"""
import numpy as np
import pandas as pd
from omegaconf import DictConfig
from src.settings import DATA_ROOT
def load_data(
cfg: DictConfig,
dataset_path: str = DATA_ROOT.joinpath("hcp_roi"),
):
"... |
b3f7d25394e09928201d77bbbcd5d8f3dfdbfec1979ddca372d4233e3eb539ec | Python | 1,557 | 41 | import torch.nn as nn
class GRU(nn.Module):
def __init__(self, cfg):
super(GRU, self).__init__()
self.is_bidirectional = True
self.batch_first = True
self.gru = nn.GRU(
input_size = cfg.encoder_embedding_size,
hidden_size = cfg.encoder_hidden_size, # int(h... |
a31bb0781695c1fa7069bcc55a9cc413a1e180b4b7dca7bef2ab2e29cf698887 | Python | 1,558 | 48 | # 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... |
a94996cd895d59ab1b02ce097a16138a8c17cad7eb7375bb8b1f2a53e935e7bd | Python | 1,558 | 48 | import sys
import os
import Core
import json
from pylab import *
ioff()
def main(fname, param=None):
"""
The main function of the command line version.
Reads the content of the .json file into the option object,
and creates the core object which runs the optimization process based on the .json file.
... |
b476255b255fd9fc43db0fc3c3782ba4cb76236e22a7dd0ffa3570d694f51780 | Python | 1,558 | 66 | """
Helper functions for modeling bursts as 2D gausian functions.
Authors: James Bonaiuto <james.bonaiuto@isc.cnrs.fr>
Maciej Szul <maciej.szul@isc.cnrs.fr>
Adaptation: Sotirios Papadopoulos <sotirios.papadopoulos@univ-lyon1.fr>
"""
import numpy as np
# 2D gaussian
def gaus2d(x=0, y=0, mx=0, my=0, sx=1, s... |
219f29fc5549c0c6bb22e315d5e1d7f3092d3cabc2873ee44b89f6d657597905 | Python | 1,560 | 55 | from typing import Optional, Callable
import jax.numpy as jnp
from netket.utils.types import DType, PyTree, Array
from netket.hilbert import AbstractHilbert
from netket.operator import ContinuousOperator
class UFromHOperator(ContinuousOperator):
r"""This is U = Exp[-1j H dt] \approx 1 - 1j*H*dt"""
def __i... |
5c21ad53981c6d6e7bb6ff8278a1f42c85a8e29e904ab6a3b9c16046e356c049 | Python | 1,560 | 46 | # 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... |
9d9a9734e675dc2d8139eeb3895d2736d743ba25a74a3cd038a2322dd72e589c | Python | 1,560 | 44 |
"""
DeepLabCut2.0 Toolbox (deeplabcut.org)
copyright A. & M. Mathis Labs
https://github.com/AlexEMG/DeepLabCut
Please see AUTHORS for contributors.
https://github.com/AlexEMG/DeepLabCut/blob/master/AUTHORS
Licensed under GNU Lesser General Public License v3.0
Adopted from DeeperCut by Eldar Insafutdinov
https://gith... |
b4ff96ddde1128b8b7277d3c146ff4244a3e4fe545c79429fe9e74f0dc4f7dbe | Python | 1,560 | 48 | # 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... |
47b8657caf69bb387112a0662794a4f606f83f5be7fd69cfdc6ce019824a59e4 | Python | 1,561 | 48 | #!/bin/env python3
'''
Make all classes representable in yaml
'''
import yaml
class YAML_Representer:
@classmethod
def yaml_class_name(cls) -> str:
return '!pdlfeynman.'+cls.__name__
@classmethod
def yaml_represent(cls, dumper, data):
raise NotImplementedError('Must be implemented in i... |
7f74e964b47bf1a5db4c608bfd4c16f7a22474f5b3b10f5be0d530ffac8bbc03 | Python | 1,561 | 66 | #!/usr/bin/env python
# coding: utf-8
# In[2]:
from matplotlib.colors import LinearSegmentedColormap
def grayscale_cmap(cmap):
"""Return a grayscale version of the given colormap"""
cmap = plt.cm.get_cmap(cmap)
colors = cmap(np.arange(cmap.N))
# convert RGBA to perceived grayscale luminance
... |
ae7f7f578140e1145d6bbdf488c133c7855219df897fe817df8409cb66541a43 | Python | 1,561 | 79 | import os
import numpy as np
import random
import math
import argparse
import pandas as pd
import sys
#from scipy import stats
#parser = argparse.ArgumentParser(description= 'Preprocess .vcf files')
#parser.add_argument('Num_', type=int, help= 'number of files to process')
#args = parser.parse_args()
#num_ = args.Nu... |
e40a2b33297c5ca7efa109a2e145043707e24b817cd0862c946fc0df8a8cca11 | Python | 1,561 | 47 | # 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... |
ebd333e345908c43ae691362715c94f3fe902bb847b464685ec3145a41acc69f | Python | 1,561 | 65 | import time
import datetime
import os
class progbar(object):
'''
Command line progress bar.
Parameters
----------
marker : str, optional
Progress bar marker
Returns
-------
out : progbar
Examples
--------
>>> from nrtlbox.utils import progbar
>>>
>>> pg = ... |
223cc50d3a589d10dcaf99ee24d2cef74f2a238ecbc4d9be4551cea6964a205b | Python | 1,562 | 38 | import os
import glob
base_path = "/Volumes/pommard-4/Benutzer/lm104/Zenodo/KIT_3/results"
# Iterate through each subdirectory in base_path
for patient_folder in os.listdir(base_path):
patient_folder_path = os.path.join(base_path, patient_folder)
# Check if it's a directory and starts with "P_"
if os.path... |
42068a02d38479b8ca943a73877456c2b8fe767fda1d957daefc7351ec436ffd | Python | 1,562 | 41 | """
toposampling - Topology-assisted sampling and analysis of activity data
Copyright (C) 2020 Blue Brain Project / EPFL & University of Aberdeen
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as
published by the Free Software Found... |
748644f609814df7e2b1fc0d90ad05d7117018f578d6ee462bbd146383e2e4a7 | Python | 1,562 | 46 | # Copyright 2016 Julien Danjou
# Copyright 2016 Joshua Harlow
# Copyright 2013-2014 Ray Holder
#
# 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
#... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.