sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
84dc8067ef016136a4a7640b35d862da9b913b24cf2eb198d5880991aa300939 | Python | 9,456 | 237 | '''
Correlogram.py: calculates shuffle corrected cross-correlogram, averaged across all neuron pairs
Usage: python3 Correlogram.py --file filename
Optional parameters specifying start and end time, e.g.
python3 Correlogram.py --file Ethanol10min.csv --tstart 19.792 --tend 79.792
if start and end time of spikes to be an... |
ffc87e5da0c5330adb924daf74d2889a59bf2b31293c3338bc9132759ec3d0ed | Python | 9,456 | 299 | # usage: conmap.py [-h] -i INFILES -r ROIFILE -m MASKFILE -o OUTDIR
# [--nmaps NMAPS] [--save_eta2 SAVE_ETA2] [--norm NORM_FLAG]
#
# Developed at DCCN (Donders Centre for Cognitive Neuroimaging), Donders Institute
# for Brain, Cognition and Behaviour. Radboud University, Nijmegen, The Netherlands
#
# A... |
48414692ad436db1ec2a3f5f37dcec29e1fad3cc924d1dd890380e9dea6fcf70 | Python | 9,460 | 266 | from unittest import mock
import numpy as np
import polars as pl
import pytest
from sklearn.preprocessing import LabelEncoder, StandardScaler
from eir import train
from eir.predict_modules import predict_data, predict_input_setup, predict_target_setup
from eir.setup import config
from eir.setup.output_setup import se... |
1aea24d9ee5851d83df2fc4f5e03a39c738ffd409908ca9d1d87bcecfa30ec45 | Python | 9,463 | 265 | import sys
import yaml
import os
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import pandas as pd
from scipy.stats import kendalltau,pearsonr
from matplotlib import rc
pathpath,tempstr = sys.argv[1:]
my_runsets = tempstr.split('___')
print('getting data from %s'%str(my_runsets))
cme... |
6352f6a45fc09ae3a9b978c1b1e661d10db00d08c6d34d1cb35f67a15ca1f9a0 | Python | 9,464 | 282 | # Kai Sandbrink
# 2022-07-26
# PyTorch implementation of meta-learning RNN a la Wang et al (2016)
# Helpful reference from papers with code: https://github.com/BKHMSI/Meta-RL-Harlow/tree/master/models
# %% LIBRARY IMPORT
import torch
from torch import nn
import torch.nn.functional as F
import torch.optim as optim
#... |
390f672e29349be9cca512b2f2820fcf49096bf0450813466b0d29fab244cf2e | Python | 9,465 | 184 | import os
import cv2
import time
import keras
import argparse
import PIL.Image
import numpy as np
import tensorflow as tf
import prettytable as pt
"""
Environment
! python==3.7.3
! tensorflow==1.13.1
! keras==2.2.4
innvestigate==1.0.8
scipy==1.2.1
numpy==1.16.5
pillow==6.2.1
opencv-py... |
a8c73087bebfde2ea638acce4bd2439068b20dd31fb7aa7fb51fb79b10be86e4 | Python | 9,468 | 227 | import warnings
from functools import partial
from typing import List, Tuple, Callable, Union, OrderedDict, Optional, Dict
import os.path
import os
import torch
import torch.nn as nn
from torch import Tensor
import torch.optim.lr_scheduler
from torch.utils.data import DataLoader, Dataset
from torch.utils.tensorboard i... |
7adcad45aa2275d038caa8d8d2b1f8396315f840f3647ac0c3e81450e8dbe179 | Python | 9,470 | 298 | #!/usr/bin/env python
# coding: utf-8
# <div style="hwidth: 100%; background-color: #ddd; overflow:hidden; ">
# <div style="display: flex; justify-content: center; align-items: center; border-bottom: 10px solid #80c4e7; padding: 3px;">
# <h2 style="position: relative; top: 3px; left: 8px;">S2 Project: DNA ... |
9ae14d7f20dd6e37cbb950d4c3b02c8fc1b9c6d2794f19b8373d502eb2a06582 | Python | 9,472 | 274 | # -*- coding: utf-8 -*-
# @Author : NaiChuan
# @Time : 2024/12/7 14:31
# @File : MNv4_CGBlock.py
# @Software: PyCharm
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmengine.model import constant_init, kaiming_init,trunc_normal_init,normal_init
from timm.layers import DropPath
class M... |
3d621252be60599dcea0849ce1d9650a250caf81b60a494d6ae8e08f9591ad3c | Python | 9,473 | 255 | """"""
import os
import warnings
import numpy as np
import pandas as pd
from rich.progress import track
from mcmlnet.susi.calculate_spectra import calculate_spectrum_for_batch
from mcmlnet.utils.logging import setup_logging
logger = setup_logging(level="info", logger_name=__name__)
class RecomputeMC:
def __in... |
e8458061e922be6270df099b4958fbc50fd5323a6bc6ad20fda70ef7f8c8dd0b | Python | 9,473 | 318 | """Interactive Plotly figures for ChemGraph artifacts.
Data-reading helpers are Streamlit-free so they can be unit-tested; the
figures are rendered by the pages with ``st.plotly_chart``, whose
built-in Streamlit theme adapts fonts and surfaces to light/dark mode.
"""
from __future__ import annotations
import csv
fro... |
a5873e57ced1f6542e2237ad3acd21a21d6f2295b04f04ed16bc34b9df5c73d5 | Python | 9,474 | 277 | """Shared utilities for ensemble execution in MCP servers.
Consolidates patterns that were previously duplicated across
``graspa_mcp_parsl.py``, ``xanes_mcp_parsl.py``, and
``mace_mcp_parsl.py``:
* Structure file resolution from directory or file list
* Async future gathering with error handling
* JSONL result writin... |
4910782509a7a15677dc663654bb96d0caa1f945ab128e1988bd5508877535b1 | Python | 9,475 | 185 | from estimates_loader_utils import load_estimate_labels, load_latent_variables_estimates, load_pca_embeddings
import numpy as np
from tqdm import tqdm
import pandas as pd
from sklearn.preprocessing import StandardScaler, RobustScaler
from sklearn.linear_model import LogisticRegression
from sklearn.metrics impor... |
a407df9e4d3c0bd2d5010da601fef9a16fb222aeaf7c355bae8cf94495954d2d | Python | 9,483 | 168 | #!/usr/bin/env python3
# Author: Francois Aguet
import argparse
import os
import subprocess
import gzip
import shutil
from datetime import datetime
import contextlib
@contextlib.contextmanager
def cd(cd_path):
saved_path = os.getcwd()
os.chdir(cd_path)
yield
os.chdir(saved_path)
parser = argparse.Ar... |
a811a9037d401c0dcd37e201797155ba0084b50c8b2c9a6242a8f1a4528f926f | Python | 9,483 | 206 | import argparse
from os.path import join
import pickle
import keras
from keras.optimizers import Adam
from keras.callbacks import EarlyStopping, ReduceLROnPlateau
import utils
from model_zoo import lentiMPRA
import plotting
import pandas as pd
import wandb
from wandb.keras import WandbMetricsLogger
import yaml
import n... |
f5d7dbe515bd740d5291467145b372fd4ea777af2969023a4ee1ec8374d293fd | Python | 9,492 | 235 | # so we need a comment?
import os
from argparse import ArgumentParser
import torch
from model import BERT_GAT
from torch.utils.data import TensorDataset
from torch.utils.data import RandomSampler
from torch.utils.data import DataLoader
from torch.utils.data import Dataset
from torch_geometric.data import Data
import... |
ffec5f7869317a34ee6fe2c9362cb4b4912d7edaacb10b4d63152d00d729df79 | Python | 9,493 | 254 | import torch
import torch.nn as nn
import torch.nn.functional as F
from timm.models.layers import DropPath, to_2tuple, trunc_normal_
'''
code for conv2Former
这里要把模型改成双输入的,用语融合不同层之间的特征
'''
def get_conv2d(in_channels, out_channels, kernel_size, stride, padding, dilation, groups, bias):
if type(kernel_size) is int:... |
d588db2e95ca00f94b269e3f194186779fd2ea8e9c34850695f63dc8bbca3032 | Python | 9,496 | 244 | #!/usr/bin/env python3
import os
import re
import json
import argparse
from collections import defaultdict
import numpy as np
import pandas as pd
from PIL import Image
import torch
import torch.nn.functional as F
from torch.utils.data import Dataset, DataLoader
from torchvision import transforms
fr... |
a3019f5c7ab1999b93b4781d720acdad9265d5271878da9ef6cd2d12b60c99b3 | Python | 9,501 | 252 | import numpy as np
import polars as pl
from matplotlib.axes import Axes
from tqdm import trange
from typing import Literal, NamedTuple
from argclz import AbstractParser, argument
from neuralib.io import csv_header
from neuralib.locomotion import CircularPosition, running_mask1d
from neuralib.plot import plot_figure
fr... |
10e005b7c95518de72427256d6d97d20a0cd1b795b02dc6b41b8d47126e68454 | Python | 9,503 | 228 | #! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Compute the axial (para_diff), radial (perp_diff), and mean (iso_diff)
diffusivity priors for NODDI.
---------------------------------------------------------------
Reference:
[1] Zhang H, Schneider T, Wheeler-Kingshott CA, Alexander DC.
NODDI: practical in vivo ... |
da1316d7a66fb37ce3c4c9e90aeb4048c6851ca57f8e54fdcfbda1e9472a5fbc | Python | 9,503 | 308 | import argparse
import datetime
import os
from collections.abc import Iterable
from itertools import chain
from docs.doc_modules.a_using_eir import (
a_basic_tutorial,
b_tabular_tutorial,
c_sequence_tutorial,
d_pretrained_models_tutorial,
e_image_tutorial,
f_binary_tutorial,
g_multimodal_tu... |
6ff029e2e9b4f9da35b3cbabb8a6bf93ebddc6fbfe0be36d0ac8101203959efd | Python | 9,509 | 252 | # -*- coding: utf-8 -*-
# python standard library inputs
import sys
# external inputs
import numpy as np
import nibabel as nb
from numpy.fft import fft, ifft, fft2, ifft2
# local inputs
from ..simulation.get_white import get_white_2d, get_white_1d
from ..simulation.filter_odc import filter_odc_2d, filter_odc_1d
from... |
9eaadb9798388b7d2e05364dacfa01836195465793fb05d13fe631bc8f589e72 | Python | 9,509 | 223 | import numpy as np
from matplotlib.axes import Axes
from mpl_toolkits.axes_grid1 import make_axes_locatable
from argclz import AbstractParser, argument
from neuralib.io import csv_header
from neuralib.plot import plot_figure, ax_set_default_style, VennDiagram
from neuralib.plot.plot import axvline_histplot
from neural... |
fbf4c588bc4d13a506020d6244ef585f8d90ca9347843c7c593fdb71c2c315ac | Python | 9,510 | 299 | """Classes and functions to make topoplots."""
from typing import List, Optional, Union
import numpy as np
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
from scipy.interpolate import griddata
from osl_dynamics.files.scanner import layout... |
167606b534023d6e39ed80b58417fc84348b6060d7ee3afb7fb7751f16004204 | Python | 9,512 | 250 | """Sinc-based convolution
Mirco Ravanelli, Yoshua Bengio,
"Speaker Recognition from raw waveform with SincNet".
https://arxiv.org/abs/1808.00158
"""
import numpy as np
import torch
import torch.nn.functional as F
import torch.nn as nn
import sys
from torch.autograd import Variable
import math
import matplotlib.pyplot a... |
2568cfbeae25ad0f57525b8766c6ef5f825532435c16ed7d8d1c020aab55be18 | Python | 9,521 | 275 | """
https://github.com/lijunRNA/RNA3DCNN/blob/master/PixelateResidue.py
"""
from Bio.PDB.vectors import Vector
""" atom name """
ATOMS_NAME = ['P', 'OP1', 'OP2', 'O5\'', 'C5\'', 'C4\'', 'C3\'', 'O3\'',
'O4\'', 'C1\'', 'C2\'', 'O2\'', 'N9', 'C8', 'N7', 'C5', 'C6',
'O6', 'N1', 'C2', 'N2', 'N3... |
b759a10b247f5651bb18f1b28784fea04f035305d51a8d9d8ebbb01ffed1f147 | Python | 9,523 | 127 | """ This script investigates the features within the components of the trained neural network.
This version's cropping tries to avoid the radar echo to be included.
"""
import os
import argparse
from utils.env_config import setup_environment
import timm
from data.dataloader import prepare_dataloaders
from model_an... |
cc1551e72b43c414a4d512086a1d30199121e6dc1bac7f14fff40c0761532be0 | Python | 9,523 | 208 | import tensorflow as tf
import tensorflow.keras.layers as L
from tensorflow.keras import backend as K
NUM_TARGET_FIDS=13
NUM_TARGET_CONCS=12
NUM_TRAIN_SAMPLES=100,000
BATCH_SIZE=16
NUM_EPOCHS=15
LEARNING_RATE=5e-4
# Default distribution strategy for single GPU is:
# strategy = tf.distribute.get_strategy()
# if TPU... |
7c4ad3f976541876c77c45d7a578f456e6ab15f91886421d818777a095b53959 | Python | 9,525 | 264 | # 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... |
d8dc86cf71c5163e678a82b52dbf5fcffd66529af186e3d98cb7101fb490b820 | Python | 9,528 | 195 | import torch
from typing import Any, Dict, List, Union, Sequence
from ..util.util import asnumpy, get_tiling_slices
from torch import Tensor, nn
from collections import OrderedDict
from lightning_fabric.utilities.rank_zero import rank_zero_only
from ..data.instance_eval import LabelMatcher
from ..data.cpn import contou... |
35768d975445e87688be74cb9c21ca5e67d1e84a7312d27b76e95fa1c9f9ba88 | Python | 9,529 | 245 | # -*- coding: utf-8 -*-
"""
Created on Mon Oct 31 09:05:53 2022
@author: tianj
"""
# -*- coding: utf-8 -*-
"""
Created on Thu Oct 20 19:39:51 2022
@author: tianj
"""
import torch.nn as nn
import numpy as np
import save_networks
import torch
import tqdm
import losses
from save_networks import s... |
a006af0f17c0078b1adb4b5abbfcc7e2debae43790a2d354c294c1740e4ac21c | Python | 9,531 | 295 | """Module for quick LLM evaluations"""
from deepdiff import DeepDiff
from chemgraph.models.ase_input import ASEInputSchema
def remove_ignored_fields(obj, ignored_keys=("cell", "pbc")):
"""Remove ignored fields from object
Args:
obj (_type_): _description_
ignored_keys (tuple, optional): _des... |
a518acab371d9cb98ccc13df381213dada8f37b1c936e1e20c64d7ef108a0cd7 | Python | 9,531 | 238 | from __future__ import division
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
import numpy as np
import os
from data_reader import DataConfig
from detect_peaks import detect_peaks
import logging
class EMA(object):
def __init__(self, alpha):
self.alpha = alpha
self.x = 0.
... |
8782c67f63c505cb04c7732c8cf1552a907033c8087cd21d2367cb522dca9cad | Python | 9,532 | 310 | import json
import random
import torch
torch.manual_seed(123)
import numpy as np
import pandas as pd
from jarvis.core.graphs import Graph
from jarvis.core.atoms import Atoms
from pymatgen.io.jarvis import JarvisAtomsAdaptor
from pymatgen.core import Structure
#from alignn.models.alignn import ALIGNN
from alignn_mult... |
8fa1ec5c4bb2ae21aa6970e5066fd4228bd77edfda9808d3f763297aaf6805fc | Python | 9,537 | 299 | from collections.abc import Sequence
from pathlib import Path
from shutil import copytree
from docs.doc_modules.e_pretraining.utils import get_content_root
from docs.doc_modules.experiments import AutoDocExperimentInfo, run_capture_and_save
from docs.doc_modules.utils import get_saved_model_path
from eir.utils.logging... |
eb04ffe0df46de32394c637219e5e106c2db27356738257bb2ac498f782df0ac | Python | 9,538 | 269 | import numpy as np
import sys
import os
import yaml
import h5py
import time
import multiprocessing as mp# original multiprocessing Pool much faster than threadPool!
from datetime import timedelta
pathpath,recfilename,chanflav, regstr = sys.argv[1:]
regs_of_interest = [bla.strip() for bla in regstr.strip('[]').replace... |
745dc6504609df5d950a89ba902fbb81d128f935d8c44e9b5bdb78c7bda3e5c6 | Python | 9,539 | 234 | #!/usr/bin/env python
"""
Interface to a Logitech gamepad F310 joystick.
The joystick needs to be in "direct input" mode.
This is done using the switch on the back of the joystick.
Hazen 9/12
Jeff 9/12
Jeff 6/21
"""
import pywinusb.hid as hid
class GamepadF310(object):
"""
This class encapsulates the inter... |
976ef016b2439c35ac1b13a073b4d4cb657c71c547283a39f659e432fe8c8237 | Python | 9,540 | 302 | """
Some algorithms from the original skyline implementation are commented out and
the best combination of algorithms for NAB is included below.
"""
from datetime import datetime, timedelta
import numpy as np
import pandas
def tail_avg(timeseries):
"""
This is a utility function used to calculate the average o... |
75048c0fe777694070a14f8b25b93f9f1131ad2696596d6d312239ee35a16f6e | Python | 9,541 | 354 | from typing import Any, List, Optional, Union
import matplotlib.pyplot as plt # type: ignore
import pandas as pd # type: ignore
import seaborn as sns # type: ignore
from anndata import AnnData # type: ignore
from matplotlib.axes import Axes # type: ignore
from mpl_toolkits.axes_grid1 import make_axes_locatable #... |
8d00922b748d5bb04c85c1586c839c19aa8a8751b1bc8e4b2799e34f35295462 | Python | 9,541 | 236 | import torch
import torch.nn as nn
from torch.nn import init
from functools import reduce
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
# define your custom model here:
class SKConv(nn.Module):
def __init__(self, in_channels, out_channels, stride=1, M=2, r=16, L=32, groups=32):
... |
a678c256923f51f27e8e807a6ba64728664e387766871bd61d816fc3dcd0db53 | Python | 9,544 | 236 | # This file is part of connectome-manipulator.
#
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2024 Blue Brain Project/EPFL
"""Main module for structural connectome comparison:
- Loads two SONATA connectomes
- Extracts structural properties (compute_results), as specified by the structural comparator config d... |
ae1ef25c6e8993e262918079dd7c323e75a4449b563efc1fe524141c915c13ae | Python | 9,544 | 237 | import torch
import torch.nn as nn
from torch.nn import init
from functools import reduce
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
# define your custom model here:
class SKConv(nn.Module):
def __init__(self, in_channels, out_channels, stride=1, M=2, r=16, L=32, groups=32):
... |
69938ca96a284403857b797298281cffb7b6151b29d956e2dc8819501decfcd6 | Python | 9,546 | 265 | from PIL import ImageFilter
import random
from anndata._core.anndata import AnnData
import torchvision.datasets as datasets
from torch.utils.data import Dataset
import scanpy as sc
import torch
from copy import deepcopy
import numpy as np
import pandas as pd
class scRNAMatrixInstance(Dataset):
def __init__(se... |
3c181727ff890144a0e4f2339b12cd8ec1c77cd7ca03713bad03cb7c5216ee1e | Python | 9,547 | 292 | # Copyright 2024 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... |
9415983de2e00a711563787fc5d9869aa19de22c9135cde31ad3730ac89e24b1 | Python | 9,550 | 272 | # Copyright 2024 Google LLC
# 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
db1f2e37cd01c16da97411ad5382cd17ef2952d199331af46ed40255281e2b00 | Python | 9,550 | 248 | import os.path as osp
from pathlib import Path
from typing import Any, Dict, Optional, Union
import torch
from torch_geometric.io import fs
try:
from huggingface_hub import ModelHubMixin, hf_hub_download
except ImportError:
ModelHubMixin = object
hf_hub_download = None
CONFIG_NAME = 'config.json'
MODEL_... |
a2567884f5839753409602904177ebb30ccb30df67477940a29263d76c116d7e | Python | 9,552 | 198 | # Copyright (c) 2022, Kwanhyung Lee, AITRICS. 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 ... |
6b1ec68689d9e4af068daed13060b9a845fd7f4351d4ab39ef8da38ccb7f1e78 | Python | 9,559 | 203 | """A module that contains unit tests for the :py:mod:`corelay.io.hashing` module."""
import importlib
import sys
import typing
from io import BytesIO
from types import ModuleType
import numpy
import pytest
import corelay.io.hashing
from corelay.io.hashing import HashPickler, Hasher, TensorPlaceholder, Tensor
def t... |
16b91b5ec9f6953f5daf118898858ae5e6c51244f7465343e75a6e583046f5ad | Python | 9,565 | 223 | # %%
import pandas as pd
import numpy as np
from os.path import join, exists
from tqdm import tqdm
from matplotlib import pyplot as plt
import torch
from torch.nn import functional as F
from segment_anything import sam_model_registry
import SimpleITK as sitk
import random
import os
import cv2
from skimage import io, me... |
dfa69f6c7e9d49cecd6f693c11285ef9e41dff6b32f6a8ad464b8b75028e9be0 | Python | 9,566 | 267 | # adopted from
# https://github.com/openai/improved-diffusion/blob/main/improved_diffusion/gaussian_diffusion.py
# and
# https://github.com/lucidrains/denoising-diffusion-pytorch/blob/7706bdfc6f527f58d33f84b7b522e61e6e3164b3/denoising_diffusion_pytorch/denoising_diffusion_pytorch.py
# and
# https://github.com/openai/gu... |
a10128a74c978f0a47ddec8181718212e8230ab181255239097f7d13bb06a049 | Python | 9,574 | 266 | # -*- coding: utf-8 -*-
"""
Created on Sun Nov 27 18:43:17 2022
@author: DODO
"""
import numpy as np
import sys
import os
from os.path import getsize
import time
import datetime
import matplotlib.pyplot as plt
import scipy.interpolate as itp
from scipy import optimize, linalg
from deap import algorithms, base, creato... |
675ac506953c659898c7e2a9caa5bd2a61104de38d644467599fc98510f7dda5 | Python | 9,577 | 196 | import pickle as pkl
import numpy as np
import argparse
import json
from system import System
from tqdm import tqdm
import os
from joblib import Parallel, delayed
parser = argparse.ArgumentParser()
parser.add_argument('--simulation', type=str, default='charged',
help='What simulation to generate.'... |
595babd824d7f43c0caada26941a4f87472a61da0ee6e0e50c64624ccc57969e | Python | 9,583 | 175 | #----------------------------------------------------#
# 将单张图片预测、摄像头检测和FPS测试功能
# 整合到了一个py文件中,通过指定mode进行模式的修改。
#----------------------------------------------------#
import time
import os
import cv2
import numpy as np
from PIL import Image
from deeplab import DeeplabV3
os.environ["CUDA_VISIBLE_DEVICES"]='4'
if __n... |
8005c25cd6d2f50dddc2b241ac2cff23e120844ab6f3e34f5ed503e6fd63dfdd | Python | 9,584 | 314 | import warnings
import numpy as np
from .. import compute, utils
from ..base import BasePLS
from ..structures import _pls_input_docs
class MeanCenteredPLS(BasePLS):
def __init__(
self,
X,
groups=None,
n_cond=1,
mean_centering=0,
n_perm=5000,
n_boot=5000,
... |
e94768742614aa42f9782d3d9333a49d6e276c48210fa19a8304f69882790d7a | Python | 9,585 | 312 | import argparse
import os
import random
import sys
from typing import List
import pandas as pd
from dotenv import load_dotenv
sys.path.append("..")
sys.path.append("../backend")
from backend.model.topic import TopicModel, UserEvaluationDao, UserEvaluationModel
from backend.model.user import UserDao, UserModel
# Car... |
771a969e3ca3224e74af29a07102a1ff1d79894fd154178c00e4b4ce5a45ce02 | Python | 9,586 | 254 | """Prepare, execute, and parse single-component gRASPA-SYCL simulations."""
from __future__ import annotations
from importlib.resources import files
import json
import logging
import math
import os
from pathlib import Path
import re
import shutil
import subprocess
import tempfile
import time
import warnings
import n... |
adcf3480ca8a3b8b8fd45ecadbeeb045a1cbcc2ef43ff4f52cdca6099410bb5e | Python | 9,586 | 218 | import torch
import numpy as np
from pandas import DataFrame
from .motifs import Motif
from .data_utils import DNAPredictGenerator
from .plot_utils import plot_ig
class GradientDescent():
'''Searching for the best substitution in the input sequence for some \
feature appearance in prediction using gradi... |
d9c6f0deb4a0f147856e04037a3b5485fc93eb9fcc3b1bc96630584ed16771c4 | Python | 9,588 | 295 | import torch
import torch.nn.functional as F
import numpy as np
from typing import Tuple, Optional, Union
def create_2d_displacement(
shape: Tuple[int, int],
alpha: float = 10.0,
sigma: float = 3.0,
device: Optional[torch.device] = None,
random_state: Optional[np.random.RandomState] = None
) -> Tup... |
c9ec613de530392dfaac728224e1e04618065b9e9821342449cd7ddc6c8cafa8 | Python | 9,593 | 270 | """
Train a BCAE_VS model on time projection chamber (TPC) data.
BCAE_VS stands for Bicephalous Convlutional Autoencoder with
Variable compression ratio for Sparse input.
"""
import os
import sys
from pathlib import Path
from pprint import pprint
import yaml
import pandas as pd
# == torch ============================... |
c5279f6f99a731cf3e74c5304dc193ced9be46dcd05dcafb3953c22dde27e686 | Python | 9,595 | 203 | import sys
import numpy as np
import os
import pandas as pd
from os.path import exists
from nibabel.freesurfer.io import read_morph_data, read_annot
from nibabel.freesurfer.mghformat import load
from collections import defaultdict
from MIND_helpers import calculate_mind_network, is_outlier
def get_vertex_df(surf_dir, ... |
d4122e38b50f528c846a45093e205d5128cf6232a81b352999eaae531f7641a3 | Python | 9,595 | 353 | # -*- coding: utf-8 -*-
"""Input/Output surface utilities."""
import datetime
import os
import shutil as sh
import sys
from pathlib import Path
import nibabel as nb
import numpy as np
from nibabel.freesurfer.io import (
read_label,
read_morph_data,
write_geometry,
write_morph_data,
)
from nibabel.free... |
0051cabe778dbd1cc16ab3f43476603ed92dd140626a5fa9c0932bb72b5662aa | Python | 9,597 | 218 | """Shared configuration, class-order, and checkpoint utilities (lazy ML imports)."""
from __future__ import annotations
import csv
import hashlib
import json
import random
from dataclasses import asdict, dataclass, fields
from pathlib import Path
@dataclass
class TrainConfig:
model_name: str = "resnet18.a1_in1k"... |
0eb4ad169e00beadfa50c873fcbd72b403f6c29a005f6210354c279c9fa5475f | Python | 9,600 | 226 | # 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 numpy as np
import torch
from torch import nn
from typing import Any, Optional, Tuple, Type
from .common import L... |
c04340aa1e16f0a83c62c11859d74a1758bf0a0e82ee10d4620ec5ef09b8dd73 | Python | 9,601 | 251 | #!/usr/bin/env python3
"""code1_dvh_preprocess.py ⟶ processed_dvh.xlsx + cDVH_csv/ + dDVH_csv/
================================================================================
Reads every *.txt DVH in a source folder, extracts header metadata, detects
whether the curve is *cumulative* or *differential*, conver... |
7ff18e3f7178f7816aa4caf81716ed382b282d72b333e7551fff9ff6b4ab9b66 | Python | 9,602 | 344 | # -*- coding: utf-8 -*-
"""
Inteface to Illastik for pixel classification / object detection
This module allows to integrate ilastik into the *ClearMap* pipeline.
To use ilastik within *ClearMap* use the followng steps:
* start ilastik interface (e.g. manually or using
:func:`~ClearMap.Imageprocessing.Ilastik... |
a3dabec84439b513cc94359f1a879bc2028b69c84a7deba062047a1652f2669b | Python | 9,603 | 283 | # Generated by Django 4.2.15 on 2024-09-23 13:11
from collections import defaultdict
from collections.abc import Collection
import django.db.models.deletion
from django.db import migrations, models
from django.db.models import Count, Q
import cvat.apps.engine.models
def get_frame_step(db_data) -> int:
v = db_d... |
5596b24f7ce34b9808a8dbd8cbe1d02e14081b3e560eaeb5a8355ed1dea70251 | Python | 9,608 | 235 | from nems.models import Model
from nems.layers.base import Layer
import numpy as np
class MultiTaskModel(Model):
"""Multi-task variant of NEMS Model supporting multiple output heads"""
def __init__(self, shared_layers=None, tasks=None, task_layers=None, **kwargs):
super().__init__(**kwargs)
... |
68f8f93bd7cf7a028a21262c95d95ede4c0017c9f0024bb093668bbaebbca665 | Python | 9,609 | 231 | from collections import OrderedDict # pylint: disable=g-importing-member
import torch
import torch.nn as nn
import torch.nn.functional as F
import functools
from brainscore_vision.model_helpers.activations.pytorch import load_preprocess_images
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrap... |
dae5710e0bf31b8edbfe58c261ea79213d941fac3328fa10777fd48b18fa8b8d | Python | 9,609 | 231 | from collections import OrderedDict # pylint: disable=g-importing-member
import torch
import torch.nn as nn
import torch.nn.functional as F
import functools
from brainscore_vision.model_helpers.activations.pytorch import load_preprocess_images
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrap... |
3796c3c93bbec96aadc41bdfe701b3c2d2dd8c57e72012163aec00af8774f1ea | Python | 9,614 | 263 | """Persistent logical Academy agent for ChemGraph campaigns."""
from __future__ import annotations
import asyncio
import time
from collections.abc import Mapping, Sequence
from pathlib import Path
from typing import Any
from academy.agent import Agent, action
from academy.agent import loop
from academy.handle import... |
b98ac53410f9d2eac7ee040dec0860eb0c05db43b1acf01d5b7d491eb067e9dd | Python | 9,614 | 280 | """Extend JSON encoding/decoding to work with `numpy.ndarray` and NEMS objects.
When encoding `obj` with `name = type(obj).__name__`, if an `encode_{name}`
method is found then that method will be used. Otherwise, the json package's
default encoding method will be used (`json.JSONEncoder.default`).
Warnings
--------
... |
bdb94af876f6df694095b52e953a78343603e9b7177d02d613a929f313a5e2a8 | Python | 9,614 | 323 | import os
import platform
import shutil
from collections import namedtuple
from typing import NamedTuple, Optional
from urllib.parse import urljoin
import ngs_tools as ngs
PACKAGE_PATH = os.path.abspath(os.path.dirname(__file__))
PLATFORM = platform.system().lower()
CPU = ''
if PLATFORM == 'darwin' and platform.proce... |
1e0f7f46a7b342bd8f9498b3ca93874191b9cf5160a7d053649894515f2af959 | Python | 9,615 | 256 | import multiprocessing
multiprocessing.set_start_method('spawn', force=True)
import os
import click
import time
import random
import numpy as np
from concurrent.futures import ProcessPoolExecutor, as_completed
import multiprocessing as mp
def run_single_seed(seed_idx, network_config_file_name, data_dir, num_gpus, deb... |
e3ef7f606ebc3b4c19aa404e599ebefa1dd1a646f611cc127e37b78ef9273e55 | Python | 9,617 | 222 | """Test the HTML report's embedded CSV previews.
Run from the repo root::
uv run python python/test_report_csv_preview.py
The report is meant to be opened straight off disk. A page on a ``file://``
origin cannot fetch its sibling files — browsers give each one an opaque origin
— so the preview rows cannot be loa... |
cee17b4bd642d03166321cc811b42c49d7a954588db0d05d3c285cf558a28d58 | Python | 9,619 | 189 | from pathlib import Path
import numpy as np
import pytest
from pytest import approx
from brainscore_core.supported_data_standards.brainio.assemblies import BehavioralAssembly
from brainscore_vision import benchmark_registry, load_benchmark
from brainscore_vision.benchmark_helpers import PrecomputedFeatures
from brain... |
204887141e445da7eacdc7b6ca5fe1f5beb22e2f13b6b1f207864f2d10dab029 | Python | 9,621 | 246 | from PySide6.QtCore import QObject, Signal, Slot
from bread.data import Lineage, Microscopy, Segmentation, SegmentationFile
from typing import Optional, List
from dataclasses import dataclass, field
from pathlib import Path
from ._utils import clamp
import logging
logging.basicConfig(level=logging.INFO)
logger = loggi... |
aa0495fc7c75bcacd19dedecc92164db65251814cf1e2562fac9f99568ae0c94 | Python | 9,624 | 292 | # Copyright 2024 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... |
f202f09d058c0dfb189f908a45a0833280b9ce37b5c0b285c9400d97cdbc8e36 | Python | 9,626 | 267 | # Copyright (c) 2022, Kwanhyung Lee, AITRICS. 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,
# W... |
e03cc39e9f9d76384def85817389486e6e7f71e330390de5b544a7eed8d409f9 | Python | 9,631 | 272 | # Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved
"""Utilities for masks manipulation"""
import numpy as np
import pycocotools.mask as maskUtils
import torch
from pycocotools import mask as mask_util
def instance_masks_to_semantic_masks(
instance_masks: torch.Tensor, num_instances: torch.... |
bc98d33b4b3432b4eb625f61fb67c60a3951fca4639f4a02f4df639c6577bc2e | Python | 9,633 | 286 | """
gradients.py
============
Gradient-based analysis and inter-areal laminar dissimilarity.
Simplified demo version for the Schaefer-400 parcellation. Contains only the
two functions used by the demo notebook:
- run_gradient_analysis_auto : BrainSpace gradient estimation with
automatic component selection ... |
ef022ae1ea654933d243ead488cb1846381372781bcbbe8caa7eb9fd34283d91 | Python | 9,633 | 299 | """
Improved setup script for TChemGNN - handles Windows compilation issues.
Replace your existing setup_script.py with this version.
"""
import subprocess
import sys
import os
import platform
import torch
def get_pytorch_info():
"""Get PyTorch version and CUDA info for wheel selection."""
try:
impor... |
f0995c9aab8e8156b865479c7d79f22468907358361a8fb4b7a178589bf8860e | Python | 9,643 | 247 | import time
import logging
import numpy as np
from scipy.spatial import KDTree
from scilpy.tracking.fibertube_utils import (streamlines_to_segments,
dist_segment_segment)
from dipy.io.stateful_tractogram import StatefulTractogram
from scilpy.tracking.utils import tqdm_if_ve... |
504d344ae7f8d8b17ced9f4b9936431f84fc3af5f581c759019774711c56b8fc | Python | 9,644 | 286 | import os
import re
from itertools import product
from bids.layout import BIDSLayout
def read_bids_dataset(bids_input, subject_list=None, collect_on_subject=False):
"""
extracts and organizes relevant metadata from a bids dataset necessary
for the dcan-modified hcp fmri processing pipeline.
:param b... |
54b19c78fa220f163a70b4780305cb0f643ed9e46345621e8ecd2196dab30199 | Python | 9,647 | 179 | import os
from glob import glob
import json
import numpy as np
import skimage.io as skio
from natsort import natsorted
from metrics import generate_dice_scores, instance_dice
from skimage.morphology import label
from napari_simpleitk_image_processing import label_statistics
from helper import generate_lhc_sample, boun... |
3d7f47578f7b6fa5ecbe013eff98e6cb8a85575d73c222372852c9f1298d0014 | Python | 9,648 | 273 | # Copyright 2014-2015 Numenta Inc.
#
# Copyright may exist in Contributors' modifications
# and/or contributions to the work.
#
# Use of this source code is governed by the MIT
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT.
import multiprocessing
import os
import pandas
tr... |
c4d3e0faf9591475a8128712a5e037892397a58f301289377f85240938b72fba | Python | 9,648 | 260 | # Copyright (c) DP Technology.
# 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 torch
import torch.nn as nn
import torch.nn.functional as F
from unicore import utils
from unicore.models import BaseUnicoreModel, register_m... |
af356909f3330d5eb0d91c26f726fe2b99d0295933b4fea2cb1406fccac6d6ac | Python | 9,649 | 227 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Performs an operation on a list of streamline files. The supported
operations are:
difference: Keep the streamlines from the first file that are not in
any of the following files.
intersection: Keep the streamlines that are present in all files.
uni... |
757b34705e2a623cc0b50dcc40633bca7a9a6341a05e1c90d38358a91a10ddc9 | Python | 9,650 | 210 | #This is the python program that reads in Calcium current traces from 2 Pulse protocol
#extracts baseline values, peak currents, steady state, and performs leak subtraction
#input is the full filename (including directory) of one of the traces, then python will find all the rest of the traces
#Outputs single file with ... |
77edf55ef194841786030fffded2096f03a9c29ca16c243d398738862542254d | Python | 9,651 | 224 | import pandas as pd
import numpy as np
import sklearn.neighbors
import scipy.sparse as sp
import seaborn as sns
import matplotlib.pyplot as plt
import torch
from torch_geometric.data import Data
def Transfer_pytorch_Data(adata):
G_df = adata.uns['Spatial_Net'].copy()
cells = np.array(adata.obs_names)
cell... |
accf3cf3442bfd3dd9cf5d3543bf2c6966b41177a214e40eab62b6a574a9fc8b | Python | 9,652 | 310 | from __future__ import absolute_import, unicode_literals
import pickle
import re
import jieba
from .viterbi import viterbi
from .._compat import *
PROB_START_P = "prob_start.p"
PROB_TRANS_P = "prob_trans.p"
PROB_EMIT_P = "prob_emit.p"
CHAR_STATE_TAB_P = "char_state_tab.p"
re_han_detail = re.compile("([\u4E00-\u9FD5... |
03b5e5ba067bf390dd6b077536b7705196d426fc8410a393f1383bed8577cd4c | Python | 9,662 | 231 | import numpy as np
import torch
from dgd import utils
from dgd.diffusion import diffusion_utils
class PredefinedNoiseSchedule(torch.nn.Module):
"""
Predefined noise schedule. Essentially creates a lookup array for predefined (non-learned) noise schedules.
"""
def __init__(self, noise_schedule, timest... |
17d75ef9ab11896fc6af3159b29408ce06441a64a6405df63bd2651613c67c2f | Python | 9,662 | 226 | #!/usr/bin/env python
# coding: utf-8
'''
Dependencies:
pip install numpy pandas pynrrd
or pip install -r requirements.txt
chmod +x script.py
This step will scale total densities globally compared to multi-scaling. Thus, this does not deal with cell transplant.
In this code we start after data was created from MERFI... |
95ded6b821b5e7250a38e0d4d793cb11e1f3f9a2efb17e5d73ce0a7e71a42945 | Python | 9,664 | 247 | """RNN model used for the MSI task.
This model is a simple RNN with a single layer of RNN cells.
The options are whether to require gradients for the input and output layers.
In the paper, input gradients are not required, but output gradients can be.
"""
from models import abstract_model
import torch
import torch.nn.... |
5a32f36a21db18ebab5f5d489fe1f412361f38903fcdb8264f207c9fb66da0bf | Python | 9,665 | 321 | import math
import pandas as pd
from brainways.utils.atlas.brainways_atlas import BrainwaysAtlas
from brainways.utils.cell_count_summary import (
cell_count_summary,
extend_cell_counts_to_parent_regions,
extend_region_areas_to_parent_regions,
get_cell_counts,
set_co_labelling_product,
)
from brain... |
9631b7f890140d2a48665694cf78a6de095b1e33eafdbc8550444b89ec5d394a | Python | 9,665 | 328 | # 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, software
# distributed under th... |
750cfaf0041eb77c5a4114e12d69bf10b9976bbc95fc6e962dce348a8070f68b | Python | 9,667 | 275 | import os
import random
import shutil
import zipfile
import nibabel as nib
import numpy as np
from tensorflow.keras.utils import get_file
from tqdm import tqdm
# if wget is installed remove the following line from comment
# import wget
# if already in the abc/DeepReg directory then do nothing, otherwise
# use os.chd... |
a733b03659fc379258bdc708b79b938e4e3fe9283d02607f7c4558577ad442ee | Python | 9,669 | 211 | """Sphinx extension: a reference page per pipeline module, generated from its definition.
Every module of dmriprep and dmrifiberprofile describes itself in a ``<MODULE>.yml`` next to its code: what it does,
what it depends on and every protocol option with its type, default, choices and description. Those files are wh... |
8e9435d7f7c703821467d6010921faa709c7424ae20b8fb5c0cfd0bb10539b1d | Python | 9,672 | 298 | # -*- coding: utf-8 -*-
"""
D-P rule - Xiao data
New developmental space
New phen space
@author: Alicia
"""
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from scipy.cluster.hierarchy import dendrogram
from matplotlib import cm
import seaborn as sns
from scipy.stats import pea... |
efef80c3db7c3cda97ea1970ab830588b1720bef01491f293326a775c3ebf8ac | Python | 9,675 | 216 | from typing import Union, Tuple, Optional
from torch_geometric.typing import (OptPairTensor, Adj, Size, NoneType,
OptTensor)
import torch
from torch import Tensor
import torch.nn.functional as F
from torch.nn import Parameter
import torch.nn as nn
from torch_sparse import SparseTens... |
65bc11bc723bc759de2911d83cf0f3593270d351df1be6b187af9ac7c2d82502 | Python | 9,676 | 197 | # model.py
import torch
import torch.nn as nn
import torch.nn.functional as F
from modules import (
InstanceDropout, AdaptiveMILAggregation, MoEMILAggregation,
GradientReversalLayer, DomainClassifier, initialize_weights
)
class SCMIL_AttnMoE(nn.Module):
def __init__(self, model_params, ablation_params, n... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.