sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
0e2526c475705b77cf5b6c58c8938285eb819835d177f27b208719196579fe77 | Python | 7,201 | 209 | """Implementation of the Fisher kernel for prediction studies.
See the :doc:`HMM description </models/hmm>` for further details.
See Also
--------
`Example script <https://github.com/OHBA-analysis/osl-dynamics/blob/main\
/examples/simulation/hmm_hmm-mvn_fisher-kernel.py>`_ applying the Fisher kernel
to simulated HMM ... |
10639a065c67c6bd49a78a39f027a10d59352caf21078fe1e8acc3456c9eef59 | Python | 7,202 | 170 | """
Sliding Window Analysis
=======================
In this tutorial we will use a sliding window technique, which is a common approach for studying network dynamics, to analyse source space MEG data. fMRI data can easily be substituted.
This tutorial covers:
1. Getting the Data
2. Estimating Networks using a Slidin... |
18e4907f053b0812b9ea5420e2e870606af984164e832b5297c5090c1e72cc8a | Python | 7,202 | 163 | # Auto-anchor utils
import numpy as np
import torch
import yaml
from tqdm import tqdm
try:
from utils.general import colorstr
except:
from keypoint.utils.general import colorstr
def check_anchor_order(m):
# Check anchor order against stride order for YOLOv5 Detect() module m, and correct if necessary
... |
4bfec1ac975afc2f84dd605f35148875524b575c94c9f4c5dbc3f525367b8ef7 | Python | 7,204 | 181 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import numpy as np
import os
import tempfile
from dipy.io.streamline import load_tractogram, save_tractogram
from scilpy import SCILPY_HOME
from scilpy.io.fetcher import fetch_data, get_testing_files_dict
# If they already exist, this only takes 5 seconds (check md5sum... |
4dc032a11c49724ee8cfc582fa18f0801d5f5dd3b75fc0611256b561e200bc02 | Python | 7,204 | 149 | #########################################################################################
### Routine to determine the distribution of spikes per time bin in the whole network ###
### and in different assemblies from multiple data files ###
###############################################... |
b43aaebcd8b21c2d7e9f67efaeb22c26835e47083356cba0c23ef6d9a37eb8f2 | Python | 7,204 | 256 | P={('B', 'a'): -4.762305214596967,
('B', 'ad'): -6.680066036784177,
('B', 'ag'): -3.14e+100,
('B', 'an'): -8.697083223018778,
('B', 'b'): -5.018374362109218,
('B', 'bg'): -3.14e+100,
('B', 'c'): -3.423880184954888,
('B', 'd'): -3.9750475297585357,
('B', 'df'): -8.888974230828882,
('B', 'dg'): -3.14e+100,
('B'... |
dc52fadd032faf3c8c691eeaa33160530d8d7c1b33f86bb4573ff281040ba056 | Python | 7,204 | 213 | """The settings a run used, arranged for a person to read.
``params.json`` is the authoritative record of how a result was produced, and
it is unreadable: a flat object of ~180 keys in declaration order, most of them
at their defaults. The question a reader actually has is narrower — *what was
different about this run... |
1d3fd4fa10c5f0549193899f33723e84d73bd4bf9a92af7bfdd8129c42b3ce69 | Python | 7,206 | 210 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
"""Base callbacks for Ultralytics training, validation, prediction, and export processes."""
from collections import defaultdict
from copy import deepcopy
# Trainer callbacks ---------------------------------------------------------------------------... |
bf6c7f34c45ed30b1097fdbe6b3238ee4690e591a4513561f14ded2008c66f17 | Python | 7,207 | 186 | #! /usr/bin/env python
"""Extract subsets of a membrane graph into their own .gt/.vtp/.csv files.
This generalizes GrotjahnLab/patch_analysis/extract_single_patch.py from
"split by patch_number" into an arbitrary graph subsetter with two modes:
1. Split by a label column (one output file per unique id):
extract_... |
e8d4866df4504cfd8af4db273a6d27696a682e946731de37c1307ac81b89818d | Python | 7,208 | 149 | #########################################################################################
### Routine to determine the distribution of spikes per time bin in the whole network ###
### and in different assemblies from multiple data files ###
###############################################... |
f3a1ffaeeab75891b0b4af1ac37505bceb8816b1b310fe167c858500688cde08 | Python | 7,208 | 182 | import click as ck
import torch as th
import numpy as np
from torch import nn
from torch.nn import functional as F
import math
from torch.optim.lr_scheduler import MultiStepLR
from toolkit.utils import Ontology, propagate_annots
from toolkit.models import GINModel
from toolkit.data import load_ppi_data
from toolkit.met... |
0b2fc775f019aff7fb2186fed64112cb24befae5276152b86fc67cfb47afb023 | Python | 7,209 | 196 | from dataclasses import dataclass
from typing import TYPE_CHECKING
import torch
from torch import nn
from eir.models.layers.mlp_layers import MLPResidualBlock, ResidualMLPConfig
from eir.models.models_utils import (
calculate_module_dict_outputs,
create_multi_task_blocks_with_first_adaptor_block,
)
if TYPE_C... |
aa18222393d868419b1a011d03895ba193d2600be9f77f673e12ee13cb9d02a6 | Python | 7,209 | 188 | import numpy as np
import networkx as nx
import matplotlib.pyplot as plt
# 精细同心圆布局,基于大小进行定位并确保所有节点都在内部,调整层密度
def refined_concentric_layout_final_adjustment(G, sizes, scale=1):
pos = {}
sorted_nodes = sorted(G.nodes, key=lambda n: sizes[n], reverse=True)
num_layers = int(np.ceil(np.sqrt(len(sorted_n... |
48e6c71cdb352ed896af2ce0f5aea95c4b893fa833089023917b78c1e364de40 | Python | 7,210 | 173 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Import, extract or delete dps (data_per_streamline) information to a tractogram
file. Can be for example SIFT2 weights, processing information, bundle IDs,
tracking seeds, etc.
This script is not the same as the dps mode of scil_tractogram_dpp_math,
which performs ope... |
53a4e68c09ddc46890471a2e91139b19a555111c9159a83f135769085b01264f | Python | 7,210 | 185 | # (C) Copyright 2019 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing... |
c11e05a10c6a534bea8cf4f75b940960983030e023eeba09a2bff5a62fe79dcd | Python | 7,211 | 160 | """
Method to correct images in the movshon stimulus set by adding a cosine aperture
"""
import argparse
import logging
import os
import numpy as np
import imageio
from tqdm import tqdm
import copy
from pathlib import Path
import pandas as pd
import xarray as xr
from brainscore_core.supported_data_standards.brainio i... |
a9570f73ad668814c52af37579c3dc4402816cd3cd92216f289c427924aa0820 | Python | 7,220 | 206 | import json
import os
import shutil
import sys
import math
import requests
import psutil
import hashlib
from typing import Union, List, overload
from pathlib import Path
from lyroi.modes import get_model_folders, get_folds, get_archive_names
def format_time(seconds):
minutes, seconds = divmod(seconds, 60)
ho... |
fa9408dba005063cb726926ba38e1311a17e0aa991a0c752d0b5363fb1ba457a | Python | 7,222 | 148 | import pandas as pd
import xarray as xr
from brainscore_core.supported_data_standards.brainio.stimuli import StimulusSet
from brainscore_vision import load_dataset, load_metric
from brainscore_vision.benchmark_helpers.neural_common import (
TrainTestNeuralBenchmark, RSABenchmark, average_repetition,
filter_rel... |
d6c7444677b7e8b58071f1e3386dcab2d3e83cda1fb776eb0f8280b91770aec7 | Python | 7,223 | 206 | import torch
import numpy as np
from torch import nn
from motion.dataset import MotionDataset
def collector(batch):
"""
Rebatch the input and padding zeros for loc, vel, loc_end, vel_end.
Add the additional mask (B*N, 1) at the last.
:param batch:
:return: the re_batched list.
"""
re_batch... |
ae24cf658c753495121f92fe9d0698a7d634eb42a5f1523d1d395f2b64fd3fbf | Python | 7,224 | 143 | import argparse
import numpy as np
import pandas as pd
from scipy.io import mmread, mmwrite
from scipy.sparse import csr_matrix
import gzip, os
# load
def load_segmentation(input, approach):
if approach == "Watershed":
segmentation = np.load(input)
elif approach == "Cellpose":
data = np.load(i... |
1ff43112cc4b70361c6f0925e2f28c73d20582e2d78888c2588521d85e8173af | Python | 7,225 | 199 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
from drf_spectacular.utils import (
OpenApiParameter,
OpenApiResponse,
OpenApiTypes,
extend_schema,
extend_schema_view,
)
from rest_framework import status, viewsets
from rest_framework.decorators import action
from rest_framework... |
22df16c551ac9938c13930d04e54627e902c2b5c4b8590556862f3560621097b | Python | 7,226 | 174 | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
from torch import nn
from torch.nn import functional as F
from typing import Any, Dict, List, Tuple
from .i... |
2d501173b7345f6829f745a2ade240c98026f6b3237bf6cf8e9473405e86c54e | Python | 7,226 | 174 | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
from torch import nn
from torch.nn import functional as F
from typing import Any, Dict, List, Tuple
from .i... |
9a1e6b2467fc9ce0942b6c6e0211c9619429825f1902c6fd931103a0c2b3d6c3 | Python | 7,226 | 211 | import os
import random
import numba as nb
import numpy as np
import pandas as pd
import torch
import scanpy as sc
from sklearn.metrics.pairwise import pairwise_distances
from sklearn.neighbors import NearestNeighbors
from itertools import combinations
from torch.backends import cudnn
from tqdm import tqdm
@nb.njit('... |
e3749e55d1f1082bf9c6877ec830eba0e50058b3781baad6c493b6832e17f842 | Python | 7,226 | 180 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Extract some streamlines from your tractogram, using chosen criterion based on
streamlines' dpp (data_per_point) or dps (data_per_streamline), or filter out
streamlines.
See also:
- To modify your dpp / dps values: see scil_tractogram_dpp_math and
scil_tracto... |
4593553c37219ea872e6978c4fe20b86fc8c5e661957433bd14bf586eb342268 | Python | 7,229 | 223 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import csv
import json
import os
import random
import sys
from itertools import product
NAME = "memberships"
def read_rules(name):
rules = []
with open(os.path.join(sys.argv[1], f"{name}.csv")) as f:
reader = csv.DictReader(f)
... |
75693f6b12a6792e2a09a00a6d8de59fc5cf24a80ae0d11ada9c719bde971b7d | Python | 7,229 | 229 | import logging
from functools import cached_property
from pathlib import Path
from typing import Tuple
import cv2
import dask.array as da
import numpy as np
import pandas as pd
from csbdeep.data import Normalizer
from skimage.measure import regionprops_table
from stardist.models import StarDist2D
from brainways.pipel... |
cf785fa241c041d6cf4767c5e26467728203b06db0124a135826635a5f1c0c99 | Python | 7,235 | 142 | from train_gtex import *
import subprocess
class LitModelHeadAdapterSweep(LitModel):
"""
Offers option to freeze enformer during sweep
"""
def __init__(self, tissues_to_train,save_dir,train_dataset,learning_rate,alpha,genes_for_training,genes_for_valid,genes_for_test,eval_test_gene_during_validation... |
fe73bb70046db27caeeafeb562cfc37a0d4203a159784755782dfc1113fc33a1 | Python | 7,235 | 250 | import pytest
from magicgui import magicgui, use_app, widgets
@pytest.mark.parametrize("scrollable", [False, True])
def test_container_widget(scrollable):
"""Test basic container functionality."""
container = widgets.Container(labels=False, scrollable=scrollable)
labela = widgets.Label(value="hi", name="... |
aef74795170d28183cd16bcad68ea2d9744e26c306791f7993e5ac0257a9d99a | Python | 7,236 | 258 | import sklearn.metrics
import sklearn.neighbors
import matplotlib.pyplot as plt
import scipy.sparse
import scipy.sparse.linalg
import scipy.spatial.distance
import numpy as np
def grid(m, dtype=np.float32):
"""Return the embedding of a grid graph."""
M = m**2
x = np.linspace(0, 1, m, dtype=dtype)
y = ... |
139374d3a821bb217b0bd0b47ec98539710807da55ab1ff312da8e74dd963adf | Python | 7,237 | 187 | #pytorch tdnn model from https://github.com/cvqluu/TDNN/blob/master/tdnn.py
#tdnn+lstm example from https://github.com/kaldi-asr/kaldi/blob/master/egs/aspire/s5/local/chain/tuning/run_tdnn_lstm_1a.sh
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from builder.mod... |
77c322e313542119705fe8228a7bfdf4909a11b70c3c56ff8199e4e2294e4572 | Python | 7,240 | 194 | import glob
import logging
import os
import warnings
import h5py
import numpy as np
import pandas as pd
import torch
import matplotlib.pyplot as plt
import seaborn as sns
import shutil
from sklearn.metrics import accuracy_score, auc, f1_score, precision_score, recall_score, roc_curve
from sklearn.model_selection impor... |
983b4ded9e887093ae14faf7331890a9b3fee090686560db8e73943894d6a41d | Python | 7,240 | 299 | """
This module implements utility functions
Author:
Zhengguo Tan <zhengguo.tan@gmail.com>
"""
import numpy as np
import torch
import torch.nn as nn
import os
from datetime import datetime
from torch import Tensor
from typing import Tuple
def rss(x: Tensor,
dim: Tuple[int] = (0, ),
keepdim: b... |
4c29e08b0b59d2f2b2e6e08cf01d51d744edab8905a8402e31610d1620ddfb4d | Python | 7,241 | 164 | from collections.abc import Sequence
from dataclasses import dataclass
from typing import TYPE_CHECKING, Literal
if TYPE_CHECKING:
from eir.setup.schemas import al_max_sequence_length, al_tokenizer_choices
al_sequence_operations = Literal["autoregressive", "mlm"]
@dataclass
class SequenceOutputTypeConfig:
"... |
aefde5d6d62db99e2d799fa37a6c4b0888e723a92d075ad8924cc0fbf0af30de | Python | 7,241 | 159 | import numpy as np
import pandas as pd
import os
import time
from .entropy import get_io_entropy
def get_io_vector(Id, dataframe, meta_df, rois, labels, io_cols):
'''
Get in/out connectivity vectors for one given node.
For a node Id present in an edgelist dataframe, we aggregate all in/out connectivity b... |
2f3f91a913c7193e3e1411bb4b162eb665e425c410350e9c0d2f2fcd08796c66 | Python | 7,242 | 174 | '''
MXH
'''
import numpy as np
import sys
def intro():
print("""
SHORT List of potential energy surfaces for MXH:
P: potential energy, G: Gradient, D: Nonadiabatic coupling vector
U: diabatic potential energy matrix
UG: gradient of diabatic potential energy matrix
This is listed at the end o... |
55f31d051c1380fd43a092878488c6a75fae6e122bc348ef30a750adda990bca | Python | 7,242 | 178 | """
Aspen Plus VRFB Experimental Data Generator
Generates realistic VRFB cycling data mimicking Aspen Plus process simulation output.
Data characteristics: 10kW/40kWh industrial system, validated against pilot plant data.
"""
import numpy as np
import pandas as pd
import json
from pathlib import Path
def generate_as... |
d324b29cde892e57e7973ae6754d62ae91ba64986a94ce3208278228a5430874 | Python | 7,244 | 243 | from dataclasses import dataclass
import torch
import torch.nn.functional as F
from einops import rearrange
from torch import Tensor, nn
from eir.models.layers.norm_layers import LayerScale, RMSNorm
class LinearAttention(nn.Module):
"""
From https://github.com/lucidrains
"""
def __init__(
s... |
d8b72bc65b44873e3c2f3e09ec75bbe87b724288fcc9bad555a6668ead172a65 | Python | 7,244 | 123 | # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'camera-params.ui'
#
# Created by: PyQt5 UI code generator 5.9.2
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_GroupBox(object):
def setupUi(self, GroupBox):
GroupBo... |
203355b0222a0857897baeee6d8f92781b8cc6e9b39c180df71667cf421847ae | Python | 7,246 | 238 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
import json
import logging
import platform
import sys
import time
import traceback
from datetime import datetime
from pathlib import Path
from typing import Callable, List
import czifile
import numpy as np
import psutil
from quilt3 import Package
from tqdm... |
d1f23809fdb746e1b8bfc0ebacfb63000fe9401c0350622236fef217a8bd2d71 | Python | 7,247 | 170 | """Tests for config loading: dir normalization, required keys, and defaults."""
import os
import tempfile
import textwrap
import click
import pytest
import yaml
from surface_morphometrics import config_utils as cu
TEMPLATE = os.path.join(os.path.dirname(cu.__file__), "config_template.yml")
SIMPLE_TEMPLATE = os.path.... |
aa880913c2a70f9d44fcda5b91a4d0fee595205179cdd5659891808458b70e35 | Python | 7,248 | 193 | """Colours for the group-level comparison plots: ages and groups.
Two palettes run through every 2B/4B figure, and they are different kinds of
thing. **Ages** are ordered, so they take a sequential colormap sampled across
its range — a reader should be able to see which way time runs without reading
the legend. **Grou... |
ac528f20deb81d2ce72d07d2bf5cdc5b3f37ecfc1e46ca4b8497af0bdd5a4ead | Python | 7,248 | 166 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved
"""Provides utility to combine a vision backbone with a language backbone."""
from __future__ import annotations
from copy import copy
import torch
from torch import nn
from ... |
15cfe265882e2900828cb134031f1c13d7de56788e6053461e7c3d1f32b06b25 | Python | 7,249 | 184 | from sklearn.metrics import roc_auc_score
import pandas as pd
import os
import numpy as np
try:
import torch
except ImportError:
torch = None
### Evaluator for node property prediction
class Evaluator:
def __init__(self, name):
self.name = name
meta_info = pd.read_csv(os.path.join(os.path... |
312555801ec39c094bb1ad18467b681f49fcfa226e8f6ee7e6963217c699e538 | Python | 7,250 | 225 | import altair as alt
import numpy as np
import scipy.stats as stats
from AFQ.viz.utils import COLOR_DICT
def altair_color_dict(names_to_include=None):
"""
Given a list of bundle names, return a dictionary of colors for each
Formatted for Altair.
"""
altair_cd = dict(COLOR_DICT.copy())
for key... |
76c33779e9d6da8a6aeb303d013bf466dba626d8ec978e8a88d4d1278333f863 | Python | 7,250 | 179 | """Make a combo box's popup as wide as the options it lists.
Qt opens a combo box's popup at the width of the *box*, and the box is sized
by the form it sits in — so a narrow field lists its options in a narrow strip.
That would be harmless if the list drew its items the way the box does, but it
does not: the popup ad... |
a72fce57a3b167f18b4014789a1313a8018cb1c7720f34c3bef66765744b4969 | Python | 7,252 | 155 | # Copyright (c) 2026 Rohit Jena. All rights reserved.
#
# This file is part of FireANTs, distributed under the terms of
# the FireANTs License version 1.0. A copy of the license can be found
# in the LICENSE file at the root of this repository.
#
# IMPORTANT: This code is part of FireANTs and its use, reproduction, or... |
bb4c82b6bae00bc9e89f9af4b3e10715826def81793c4b65ad976624e6b9477a | Python | 7,252 | 204 | import argparse
import torch
import torch.nn.functional as F
from torch.utils.data import DataLoader
from ogb.linkproppred import PygLinkPropPredDataset, Evaluator
from logger import Logger
class LinkPredictor(torch.nn.Module):
def __init__(self, in_channels, hidden_channels, out_channels, num_layers,
... |
f5858d05f8ac42c8577b1f6210259f7124c0caf9b2b1b3d410c64162432cb204 | Python | 7,253 | 228 | # ============================================================================================================
# Author: Lucas Berg
#
# Program that calculates the APD of specific cells in the grid by passing a file with indexes
# from the desired cells and a certain percentage for the APD.
# e.g: APD_90 --> percent... |
48c997835f86309b0331b9cccf59b027f2e3387547357041cd25bb6826bb1f75 | Python | 7,254 | 160 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
from __future__ import annotations
import platform
from pathlib import Path
import numpy as np
import torch
from ultralytics.utils import LOGGER
from .base import BaseBackend
class TensorFlowBackend(BaseBackend):
"""Google TensorFlow inferen... |
1c1897a549a28763dcad63bffdf0c7a2290aaf845e3f4a09d98f3c1d6e0348af | Python | 7,256 | 189 | from __future__ import print_function
import os
import os.path
import sys
import gzip
import itertools
import json
import multiprocessing
import glob
import errno
import re
# List FASTQ files in directory and build list of dicts with read1/read2 pairs
def build_fastq_pairs_list(directory_path):
"""
... |
3128a801c6072830012ed8c2eab53fba68aa36458c406eba489795cbe5ba6377 | Python | 7,256 | 216 | import matplotlib.pyplot as plt
import matplotlib as mpl
import yaml
import os
import pandas as pd
import numpy as np
import h5py
import git
pathpath = 'PATHS/general_paths.yml'
with open(pathpath,'r') as f: pdict = yaml.safe_load(f)
genpath = pdict['metricsextraction']
dstpath = os.path.join(genpath,'psth_scores')
ps... |
55788afcec5044d55b84b4c4e86f1c04ca5dd75cd9a0c23d89ee286e254d70a1 | Python | 7,258 | 162 | import os
import torch
import shutil
import atom3.neighbors as nb
import atom3.pair as pair
from atom3.structure import get_ca_pos_from_residues
from utils.deepinteract_utils import convert_input_pdb_files_to_pair, convert_df_to_dgl_graph
from utils.vector_utils import residue_normals, tangent_vectors
from utils.data... |
ce3af243f41ed184ee5331fee921bfcdef583050a03dd96f2d88ed6a18d73ddb | Python | 7,258 | 213 | #!/usr/bin/python3
#
import os
import sys
import argparse
import shutil
from copy import deepcopy
import numpy as np
from sklearn.neighbors import NearestNeighbors
from uac import utils
# Create the parser
my_parser = argparse.ArgumentParser(description="UAC fibre mapping")
# Add the arguments
my_parser.add_argument... |
63c5f54b8b13c709de899de6bae4c2b28df8a85111e98f69597135a70c536c43 | Python | 7,263 | 204 | import os, sys, math, random, argparse, numpy as np
import bpy
import bmesh
import json
from math import radians
from mathutils import Matrix
print(os. getcwd())
import blender_util as bu
from lib_alban import *
# parse arguments
parser = argparse.ArgumentParser()
parser.add_argument('--nobjects', type=int, default... |
37a94c338158a1b70abbfd5814a51e0122c9af5338c52ca9fbf70a384566b9df | Python | 7,266 | 175 | #!/usr/bin/env python
# coding: utf-8
'''
Dependencies:
pip install pandas numpy pynrrd voxcell
External dependencies: get_all_filenames, get_csv_filenames, extract_prefix_from_filenames, extract_regions_from_column_names, read_and_concat_csv_files_new, combine_rows_and_calculate_average
chmod +x script.py
In this c... |
841116b09b1f914ca4961d6b5844cff38e416b5d02a345e4a315372f31b604dd | Python | 7,266 | 204 | import bz2
import shutil
from abc import ABC
from urllib.parse import urljoin
import pandas as pd
import seisbench
import seisbench.util
from .base import WaveformBenchmarkDataset, MultiWaveformDataset
class InstanceTypeDataset(WaveformBenchmarkDataset, ABC):
"""
Abstract class for all datasets in the INST... |
e36dee34f68b897a4d3ea7bf4634bfade223a1d2f78d13be143884007b242ab6 | Python | 7,266 | 190 | import brainpy as bp
import brainpy.math as bm
bm.set_platform('cpu')
class CANN1D(bp.NeuGroup):
def __init__(self, num, tau=1., tau_v=48., k=5., a=0.4, A=0.19, J0=1.,
z_min=-bm.pi, z_max=bm.pi, mbar=150, sigma_u=0, sigma_m=0):
super(CANN1D, self).__init__(size=num)
# parameters... |
0e092223a9e8f7ab3aac4754b548ecaa3220c354a6e49988f2d431fbb3363f89 | Python | 7,267 | 228 | """Custom TensorFlow regularizers."""
import numpy as np
import tensorflow as tf
from tensorflow.keras import regularizers
import tensorflow_probability as tfp
from osl_dynamics.inference.layers import add_epsilon
tfb = tfp.bijectors
class InverseWishart(regularizers.Regularizer):
"""Inverse Wishart regularize... |
b44610164ee92ee7abd7429c57302c8b4d9a638597723a09e16b38ec811112ae | Python | 7,270 | 166 | import numpy as np
import matplotlib.pyplot as plt
from qtpy.QtGui import QPixmap,QImage
def _canvas_to_rgb_array(canvas):
"""Render a Matplotlib canvas as an owned, contiguous RGB array."""
canvas.draw()
rgba = np.asarray(canvas.buffer_rgba())
return np.ascontiguousarray(rgba[..., :3])
class Help... |
58c03721cc9a586cf7162112089b3de1051930a8805c9997ee75d41194058215 | Python | 7,271 | 170 | #!/usr/bin/env python
"""
Handles the display of the current parameters for a given camera.
Hazen 04/17
"""
import importlib
from PyQt5 import QtCore, QtWidgets
import storm_control.sc_library.halExceptions as halExceptions
import storm_control.hal4000.halLib.halMessage as halMessage
import storm_contr... |
561d459b5a9bc666afa464656ca0fa7909e13f7625a424c9c50d91ea25f367e9 | Python | 7,274 | 172 | #!/usr/bin/env python3
import os
import sys
import errno
import argparse
def parse_args(args=None):
Description = "Reformat nf-core/rnaseq samplesheet file and check its contents."
Epilog = "Example usage: python check_samplesheet.py <FILE_IN> <FILE_OUT>"
parser = argparse.ArgumentParser(description=Des... |
f624c606f0445c8ac00ad98b51f3adcc7642186fd314bdbefddfd1ae24705096 | Python | 7,277 | 213 | import copy
import argparse
import torch
import torch.nn.functional as F
from torch.nn import Parameter, ModuleDict, ModuleList, Linear, ParameterDict
from torch_sparse import SparseTensor
from ogb.nodeproppred import PygNodePropPredDataset, Evaluator
from logger import Logger
class RGCNConv(torch.nn.Module):
... |
f5a0d0cb1de356aa1e840e9edbb9849466718504c72b415e1def498611302cb8 | Python | 7,280 | 163 | import os
import h5py
import numpy as np
import csv
from datetime import datetime
def find_files_by_type(main_path, file_type='.h5', start_date=None, end_date=None, sort_dates=None):
type_files = []
if start_date is not None and end_date is not None:
# Get a list of all folders in the current path (... |
978101db1a87195d39e79f16522c78c23f9b0533fe2273e5d819a0e6404323a2 | Python | 7,282 | 210 | #!/usr/bin/python
#
## @file
#
# Communicates with Thorlabs PDQ80S1 quadrant photodiode detector system.
#
# Hazen 3/09
#
from ctypes import *
import time
import os
pdq = 0
## loadPDQ
#
# Load the Thorlabs DLL for communicating with the quadrant photo-diode.
#
def loadPDQ():
global pdq
if ... |
52e99f832970a4c86fdb40c7439c779341aeeebe4380737b8ffc19d516b4599e | Python | 7,284 | 177 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Jul 31 2018
@author: Vicky
usage: python generateSummaryFiles.py metric_summary
"""
import glob, xlsxwriter, csv, sys, ntpath, os, re
from shutil import copyfile
metricsPath = 'finalreport/'
summaryPath = 'finalreport/summaries/'
def main(arg1='metric_... |
c340fc8918564a3c07028df4115c6a8da99d4a461e0e6253fd3f949fcdc8fb11 | Python | 7,284 | 175 | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
from torch import nn
from torch.nn import functional as F
from typing import Any, Dict, List, Tuple
from .i... |
4fa81b3691f01de9322d2b7ee1d886a087c0a458e1a8e4f8df77cadfea638ea5 | Python | 7,285 | 201 | import numpy as np
import matplotlib.pyplot as plt
#define constants
evtokcal = 23.060541945
def plot_corr(e_true, e_pred, F, forces, model_path):
# definitions for the axes
left, width = 0.15, 0.65
bottom, height = 0.1, 0.65
spacing = 0.03
rect_scatter = [left, bottom, width, height]
rect_... |
9aa335873e770aa143e6c7bcbd626a8bd0ec2b8f9d9c83fc62acb5590acad7c3 | Python | 7,285 | 150 | # Copyright (c) 2022, Kwanhyung Lee. All rights reserved.
#
# Licensed under the MIT License;
# you may not use this file except in compliance with the License.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTI... |
a062f278bf43c6330595a00d1a05e1d34d8870b8f59cea75176ef6bef7caf427 | Python | 7,285 | 223 | import numpy as np
import torch
from torch.nn.parallel import data_parallel
from attorch.layers import log1exp, Elu1
from attorch.module import ModuleDict
from torch import nn as nn
from torch.autograd import Variable
from torch.nn import functional as F
from staticnet import logger as log
class _CorePlusReadoutBase... |
bb1e8cf1054a1e872643919a5dce7867342a00fd7fc6a91240ae0e8b261c6812 | Python | 7,285 | 280 | #!/usr/bin/env python
"""
The basic test action as well as some sub-classes.
Hazen 04/17
"""
import os
from PyQt5 import QtCore
import storm_control.sc_library.halExceptions as halExceptions
import storm_control.sc_library.parameters as params
import storm_control.hal4000.film.filmRequest as filmRequest
import stor... |
5bc64043f4aa8c46e838af0f762b4ddcefd613de2c2dc38638cd53064d3e9d7d | Python | 7,286 | 197 | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import init
class hswish(nn.Module):
def forward(self, x):
out = x * F.relu6(x + 3, inplace=True) / 6
return out
class hsigmoid(nn.Module):
def forward(self, x):
out = F.relu6(x + 3, inplace=True) / 6
... |
9998c792feb5f8ed94c14111cb885be43daceb5c0f5d7301aff010d3a9f153d7 | Python | 7,286 | 222 | import os
import json
import sqlite3
def load_prs_metadata(json_path):
"""
Loads the prs_meta.json file.
:param json_path: Path to the JSON file.
:return: Dictionary containing PRS metadata.
"""
try:
# Read and parse the JSON file
with open(json_path, "r") as file:
... |
14406f9113aabbf084e057c648fb9b8d2ef442e9aabdbf359094d7afc720de01 | Python | 7,287 | 163 | import numpy as np
import matplotlib.pyplot as plt
from PyQt5.QtGui import QPixmap,QImage
class HelperModel():
def __init__(self,regViewer):
self.regViewer = regViewer
saggital_mid_index = int(regViewer.atlasModel.xyz_dict['x'][1]/2)
self.saggital_mid = regViewer.atlasModel.template[:,:,... |
3d55ffb6d36d9f74e8702912895bd3e7618f8a0a76a6281fb6cb4ca53ac0fca1 | Python | 7,289 | 230 | # laminar_rs/models.py
from __future__ import annotations
from typing import Tuple, List, Optional
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy.stats import zscore, pearsonr
import statsmodels.api as sm
from statsmodels.stats.multitest import multipletests
from statsmodels.stats.ou... |
8693e327f5bfd19f3f04c4deb53ba295ce738bfe54c2dec8f757b0fd019c7737 | Python | 7,290 | 187 | from pathlib import Path
from pydesigner.preprocessing import mrinfoutil
import pytest
from conftest import load_data
TEST_DIR = Path(__file__).parent
DATA = load_data(type="hifi")
PATH_DWI = DATA["nifti"]
PATH_BVEC = DATA["bvec"]
PATH_BVAL = DATA["bval"]
PATH_JSON = DATA["json"]
PATH_MIF = DATA["mif"]
def test_get... |
3f2470c059054e41f3608f25f2e85dd8cbca5101732e7df7b29d11f5bc97da10 | Python | 7,292 | 194 | import os
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import MinMaxScaler
from tqdm import tqdm
# ============================================================
# 1. 데이터 로딩
# ============================================================
def load_... |
bbc31fefd8683dc4fbda65240c462de15724745a889080ba2a1a5205ba6e3d96 | Python | 7,293 | 127 | """An example script, which demonstrates the usage of CoRelAy's pipeline and processor classes."""
from types import FunctionType
from typing import Annotated, Any
import numpy
from corelay.base import Param
from corelay.pipeline.base import Pipeline, Task
from corelay.processor.affinity import Affinity, RadialBasis... |
eb3e2319e358b6871894a73de3bb01a0931eba80813b546fb8f601c4fc9ee8c5 | Python | 7,293 | 204 | # -*- coding: utf-8 -*-
# genbed: A Python toolbox for generative embedding based classification
# Copyright 2019 Sam Harrison
# Translational Neuromodeling Unit, University of Zurich & ETH Zurich
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public L... |
ebf8a267881332a9f9cab15d24c265e3dfb5882a43f55bd44b0fc0faebd95cf5 | Python | 7,295 | 213 | import torch as th
from torch import nn
import math
class Residual(nn.Module):
"""
A residual layer that adds the output of a function to its input.
Args:
fn (nn.Module): The function to be applied to the input.
"""
def __init__(self, fn):
"""
Initialize the Residual lay... |
3df5e64979482864c049ef10e53ebfd3a3119f0a0d39a6ca3a7eca08726dcc52 | Python | 7,296 | 203 |
from __future__ import absolute_import
import tensorflow as tf
from tensorflow.image import extract_patches
from tensorflow.keras.layers import Conv2D, Layer, Dense, Embedding
import re
class patch_extract(Layer):
'''
Extract patches from the input feature map.
patches = patch_extract(patch_size)(fe... |
47ed3d0802454ec2dfd39f5cc705707849e7c4f682bea73165086174ad5084ca | Python | 7,296 | 230 | from typing import TYPE_CHECKING
import pytest
from eir import train
from tests.test_modelling.test_modelling_utils import check_performance_result_wrapper
if TYPE_CHECKING:
from tests.setup_tests.fixtures_create_experiment import ModelTestConfig
def get_parametrization(memory_dataset):
params = [get_base_... |
fa9e25dc34bdbf666dd982a3cd84c774069a0c110055a1fb3131a6d8fe287dda | Python | 7,297 | 223 | # 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... |
2a08cd37b9b8035e260609a841ee48fc3a1189e8c99dac8bb0391b8dbacc2d1d | Python | 7,300 | 228 | #Lucas Sancéré -
import os
script_dir = os.path.dirname(os.path.abspath(__file__))
import json
import os.path
import joblib
import lightgbm
import numpy as np
import xgboost
import yaml
from attrdictionary import AttrDict as attributedict
import histo_miner.utils.misc as utils_misc
from histo_miner.feature_selecti... |
7922adb13d5a321b4991275366db201958879396a04ed96e8b0bcbb55f00994d | Python | 7,300 | 177 | from rdkit import Chem
import os
import pandas as pd
from src.optimize_xtb import confgen
from src.tautomers import enumerate_tautomers
from src.orca_inputs import Calculation
from loguru import logger
PIGMENTS = "data/pigments.csv" # a csv file with pigment SMILES and other related information
INPUT_DIR = "inputs" ... |
3fc1a49217cd4d4795af33a09488ef0ee567b703255ea8ce5b6789a41b5fda5f | Python | 7,302 | 230 | from typing import TYPE_CHECKING
import pytest
from eir import train
from tests.test_modelling.test_modelling_utils import check_performance_result_wrapper
if TYPE_CHECKING:
from tests.setup_tests.fixtures_create_experiment import ModelTestConfig
def get_parametrization(memory_dataset):
params = [get_base_... |
bb6df37a97a6b1e6a762c3d2b38a9a3bcd1ba59e99d3ec443aedf5fd98d3f5dd | Python | 7,303 | 169 | """Demonstrates several preprocessing utilities.
NOTE: This script may not actually work yet!
"""
import numpy as np
import matplotlib.pyplot as plt
from nems.preprocessing import (
indices_by_fraction, split_at_indices, JackknifeIterator)
from nems import Model
from nems.layers import LevelShift, WeightChannels
... |
43a870ae9381fd8b339b1bef634af6cf4222afd65afb8dab4ea3c559afc9695f | Python | 7,304 | 159 | import numpy as np
import pandas as pd
import networkx as nx
import matplotlib.pyplot as plt
from numpy import array
import os
def sign(x):
y = 0
if x == 'support':
y = 1
elif x == 'oppose':
y = -1
return y
path0 = r'C:\Users\YHR\Desktop\YHR\硕士\知识图谱\数据\politician_0517\politician_json... |
7597cbf32ba278cf00b5c2e3405816763ffbdabbc919d0aaad250ca616230da5 | Python | 7,304 | 177 | #############################################################################
# Copyright (C) 2020-2026 MEmilio
#
# Authors: Maximilian Betz
#
# Contact: Martin J. Kuehn <Martin.Kuehn@DLR.de>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Li... |
93bba23312daf8d3674dceaf13417b74c4325e0d9ba168d16be42c3352872364 | Python | 7,304 | 221 | """Small callable facade for calibration refinement algorithms.
The copied refinement scripts are intentionally algorithm-heavy and expose
several lower-level functions. This module keeps GUI callers on a compact API.
"""
from __future__ import annotations
from importlib import import_module
from typing import Itera... |
ce6a3c37f3789b6a40a852e133c43adc1519de08b2732d99efd4bf80f57438b0 | Python | 7,304 | 177 | #############################################################################
# Copyright (C) 2020-2026 MEmilio
#
# Authors: Maximilian Betz
#
# Contact: Martin J. Kuehn <Martin.Kuehn@DLR.de>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Li... |
3c86b3a31991e4ecc0b43bf7ac020ed872c6671441c4362dc98d8382afa0d535 | Python | 7,305 | 161 | import os
from nipype import Node, Workflow
from nipype.interfaces.base import CommandLineInputSpec, File, TraitedSpec, CommandLine, Directory
from nipype.interfaces.utility import IdentityInterface
from traits.api import Bool, Int, Str
class DTIALPSInputSpec(CommandLineInputSpec):
# -a 4d nifti file
input_dwi... |
22fe25f422113857494600a63fbefdc590bbc08452084db235d07879e3da029b | Python | 7,306 | 150 | """Compare two step-1 outputs of the same recording spike by spike — a
detected file (bior1.5 / thr) against a sorted one, or any two methods.
uv run python python/compare_spike_trains.py \\
<run_A>/1_SpikeDetection/1A_SpikeDetectedData/<rec>_spikes.npz \\
<run_B>/1_SpikeDetection/1A_SpikeDetectedD... |
cfe2c2cb82f60d8c08ceddf23c212da132532b60b48ecc9e0859620f21c4bd8b | Python | 7,306 | 208 | #!/usr/bin/env python3 -u
# Copyright (c) DP Techonology, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
import os
import sys
import pickle
import torch
import lmdb
import gzip
import numpy as np
from... |
6a6d7603a128cc203ac1f0742263aca7a3d2d10fd6d980e5cb1872c946a6e1e1 | Python | 7,309 | 219 | #!/usr/bin/python
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
#
# See COPYING file distributed along with the PyMVPA package for the
# copyright and license terms.
#
#... |
b7703002819b47790c491b545edbf7c1546457a8752568b1d52d21d1c418bf25 | Python | 7,310 | 135 | # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'z-stage.ui'
#
# Created by: PyQt5 UI code generator 5.10.1
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObject... |
d4420b61a27ea98afa01031817466e2f295ceab21b22e36f0d6d021897e5545a | Python | 7,310 | 217 | # Original source: github.com/SlicerDMRI/whitematteranalysis
# Copyright 2026 BWH and 3D Slicer contributors
# Licensed under 3D Slicer license (BSD style; https://github.com/SlicerDMRI/whitematteranalysis/blob/master/License.txt) # noqa
# Modified by John Kruper for pyAFQ
# Modifications:
# 1. Only mean distance incl... |
0976f04a689cb3507906d1d4af00208a1b57435a3f24f3fa4f2fb578ef557acb | Python | 7,312 | 261 | from __future__ import annotations
import json
from functools import partial
from pathlib import Path
from typing import Final
import pytest
from PySide6.QtWidgets import QMessageBox
from pytestqt.qtbot import QtBot
from labelme._app import MainWindow
from ..conftest import close_or_pause
from .conftest import Main... |
4d398181d451f13beaeac24d72a7c4d6e1afd8dd0ccbf87269cd8bcb3c10de6e | Python | 7,315 | 188 | import os
import yaml
import h5py
import sys
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
pathpath,tempstr = sys.argv[1:]
my_runsets = tempstr.split('___')
print('Comparing %s'%str(my_runsets))
'''
my_runsets = [key for key in S.runsets.keys() if not key.count('resp')]
pathpath = 'P... |
0f41a1435f0c7deb55fc6100e18089d8df957aa79bcb05100a0bb5cb6776e8b6 | Python | 7,316 | 154 | import subprocess
import shlex
import numpy as np
import os
os.environ["OPENCV_IO_ENABLE_OPENEXR"]="1"
import cv2
import shutil
from os.path import join
intensities = np.round(np.array([0, 0.35, 0.75, 1.5, 3]), 2)
ref_reflectances = np.round(np.array([0.2, 0.4, 0.6]), 1)
test_reflectances = np.array([0.00, 0.025,0.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.