sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
d4a4be78de7a7e7d1092cc3fe82023595f084c269f30dd550fdb8c0f042ef510 | Python | 8,072 | 233 | # 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 Tensor, nn
import math
from typing import Tuple, Type
from .common import MLPBlock
clas... |
fe79ac2382e2bfbb88a8d6098a91ae8badb6392c4fee8a325a74af960b03a509 | Python | 8,076 | 191 | """Build a LAION-fMRI NeuroidAssembly from locally-downloaded GLMsingle betas.
This script:
1. Loads single-trial betas for one subject across all sessions (volumetric T1w 1.8mm).
2. Restricts to a combined ROI mask covering V1/V2/V3/V4/IT (IT = laionventral minus retinotopic).
3. Z-scores betas within session p... |
1d8fd5b7a013cb023ce7aeda7c858edeb79f30d1a7a6d5413d3d1cd5518827a0 | Python | 8,077 | 197 | """End-to-end MEA-Stim orchestration.
Ties together the ported stages in the order ``MEApipeline.m`` runs them for
``Params.stimulationMode``:
detect stim (raw voltage) -> group patterns -> clean spikes
-> per-electrode activity metrics -> reservoir matrices
-> circular-shift shuffle test ... |
6f34c0a0970cc30d9edf7deef24efeca87181d38f8c9c592cca001ac76b607ea | Python | 8,077 | 228 | # %%
import argparse
import gmsh
from mpi4py import MPI
from dolfinx.io import gmshio
import numpy as np
from dolfinx import fem, default_scalar_type
import ufl
from pathlib import Path
from dolfinx.fem.petsc import assemble_vector, assemble_matrix, \
create_vector, apply_lifting, set_bc
from petsc4py import PETSc... |
0098bc73197c0e03e4166f1f73d52f5c0da99b447c8daa68390790f897151574 | Python | 8,081 | 194 | import os
import numpy as np
import nibabel as nib
from scipy.stats import zscore
# ---------- helpers ----------
def _first_existing_path(candidates):
"""Return the first path that exists; otherwise the first candidate (let it error naturally on load)."""
for p in candidates:
if os.path.exists(p):
... |
1c64dd664139bb874c2b7ed11bb416214e96beff3964a1e08068e57c1e50b60c | Python | 8,081 | 211 | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import init
import math
class ViTBasedModel(nn.Module):
def __init__(self, pretrained=True, cut_at_pooling=False, img_size=175,
num_features=0, new_in_channels=7, norm=False, dropout=0,
num_classes=0,... |
ceb3852cc5e4dde70e8a5ce6cf1976dfef99c4e7d4baee011598c1df3e125661 | Python | 8,081 | 161 | # noinspection PyUnresolvedReferences
import math
# noinspection PyUnresolvedReferences
import pathlib
# noinspection PyUnresolvedReferences
from neuron import h
# noinspection PyUnresolvedReferences
import neuron_interface.neurosim
from .cell_modification_parameters.cell_modification_parameters import (
CellMod... |
f01fdf1e9fd95a6cdbd07cfe330fb134e7015fd1404b48ca71bc26f59061ea66 | Python | 8,081 | 172 | import torch
import torch.nn as nn
from complexPyTorch.complexLayers import ComplexBatchNorm2d, ComplexConv2d, \
ComplexLinear, ComplexConvTranspose2d, ComplexReLU
class ComplexConvLayer(nn.Sequential):
def __init__(self, complex_conv, in_channels, out_channels, kernel_size, stride,
padding=... |
1394bdf2fc1c6d3f49e12234fb3297dbf9c0d06721ba0e21bd70bc6637c72f71 | Python | 8,084 | 219 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import re
from collections import OrderedDict
def parse_arguments():
args = {}
named_args = True
for arg in sys.argv[1:]:
if not arg.startswith('--'):
named_args = False
break
if named_args:
... |
a78ef18b3fc046b7c6fecbd69742b2fd1ecaa8b61664f56124539bf5f3b82666 | Python | 8,085 | 98 | from argparse import ArgumentParser
def get_common_train_args(parser: ArgumentParser):
parser.add_argument("--desc", type=str)
parser.add_argument("--backend", default="dgl", help="dgl|pyg")
parser.add_argument("--cuda", type=int, default=0)
parser.add_argument("--folderpath", default="")
parser.ad... |
9b0f41071986aa16ef0b8e495ee76320a8c537e1336540325b00108708acd18c | Python | 8,086 | 201 | # -*- coding: utf-8 -*-
"""
EPI <-> ANA registration
The purpose of the following script is to compute the deformation field for the
registration between antomy and EPI in native space. The mask should be in ana
space. Optionally, a second mask can be applied which must be in orig space. The
script consists of the fol... |
125d3cec95f6bc0e78dd4d74f458228b4c7ed384408c74d0d4243dff9143ad33 | Python | 8,087 | 161 | # noinspection PyUnresolvedReferences
import math
# noinspection PyUnresolvedReferences
import pathlib
# noinspection PyUnresolvedReferences
from neuron import h
# noinspection PyUnresolvedReferences
import neuron_interface.neurosim
from .cell_modification_parameters.cell_modification_parameters import (
CellMod... |
396e2689c33a099afd8a8dd7909f029bd10a8b32c4b392a1762c680f49eeeaf5 | Python | 8,087 | 161 | # noinspection PyUnresolvedReferences
import math
# noinspection PyUnresolvedReferences
import pathlib
# noinspection PyUnresolvedReferences
from neuron import h
# noinspection PyUnresolvedReferences
import neuron_interface.neurosim
from .cell_modification_parameters.cell_modification_parameters import (
CellMod... |
e05ab0c31a5b1809af1c190a4d5fe21e879c4bce007102f7c22ddf6837eee005 | Python | 8,087 | 161 | # noinspection PyUnresolvedReferences
import math
# noinspection PyUnresolvedReferences
import pathlib
# noinspection PyUnresolvedReferences
from neuron import h
# noinspection PyUnresolvedReferences
import neuron_interface.neurosim
from .cell_modification_parameters.cell_modification_parameters import (
CellMod... |
ea59a0a02cec1a6b27e5d41e3dc5829ddc519a1b2613f764f9d45c84476d8f8f | Python | 8,087 | 202 | """Which metrics measure the same thing? — the port of ``featureCorrelation.m``.
MATLAB draws a grid of correlation heatmaps, one per group x DIV, and stops
there. The heatmaps are kept, and three things are added, because the question
a correlation matrix is usually being asked is not "what is r for this pair"
but "h... |
9d7a6dc3ab7e1b04eb930ba7abd393be2becaae70f778b6e4c3a9c0c1a49dc98 | Python | 8,088 | 213 | import pandas as pd
import torch
from sklearn.model_selection import train_test_split
from torch.utils.data import Dataset
import my_setup
from data_processing.sequence_utils import prepare_sequence
from data_processing.tokenization import SEPARATOR_TOKEN, PADDING_TOKEN, CLASSIFIER_TOKEN
class Measurements:
def... |
c59e0ff8fe80c057ee4657fba12c0cbe537a76d6384b835624570fb5715079bb | Python | 8,088 | 227 | from .preprocess import initialize
from .gncc import calculate_gncc
import numpy as np
import torch
import torch.nn.functional as F
def transform_image(images_repeated,
dx_gpu,
dy_gpu,
angles_rad,
memory_dict,
interpol... |
2a6cf1d6387339a7954eea80141d60abf0dbf470d7c8688346f0de73831f1385 | Python | 8,089 | 142 | # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'progression.ui'
#
# Created by: PyQt5 UI code generator 5.7
#
# 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.setObjec... |
a657000c90d700fa18c7efb665d9fe6df39ae2c8aac1c717d4820bac9fb4d799 | Python | 8,089 | 146 | """Generate offline source inventories without fitting scientific models."""
import json
from pathlib import Path
from xml.etree import ElementTree
import numpy as np
import pandas as pd
from openpyxl import load_workbook
from src.acquisition.download import ROOT, MANIFEST, sha256
def require_unique(frame: pd.Data... |
d0dc4e576b773393564b2adf3667f9560034b6891e1b582b5b309b5140c06d77 | Python | 8,090 | 161 | # noinspection PyUnresolvedReferences
import math
# noinspection PyUnresolvedReferences
import pathlib
# noinspection PyUnresolvedReferences
from neuron import h
# noinspection PyUnresolvedReferences
import neuron_interface.neurosim
from .cell_modification_parameters.cell_modification_parameters import (
CellMod... |
d9f0e8376d85568cd7cab01cd641d2840b1760bc9fdc5522e2ade367a75351fe | Python | 8,090 | 205 | import unittest
import os, sys
import numpy as np
import pandas as pd
from numpy.testing import assert_array_almost_equal
from pandas.testing import assert_frame_equal
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../../")))
from heig.wgs.vsettest import VariantSetTest, cauchy_combination
... |
52b7bba64e5f1f1997339fcb21201ddfffd13bae178b853fa3de4a30f978fdfd | Python | 8,094 | 178 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
from __future__ import annotations
import argparse
import cv2
import numpy as np
import onnxruntime as ort
import torch
from ultralytics.engine.results import Results
from ultralytics.utils import ASSETS, ROOT, YAML, nms, ops
class YOLOv8Seg:
... |
7823cb8acf26af1b04638b6a306770b6ad3fb7f9aae10db4deb105abd70cd46d | Python | 8,094 | 235 | import torch
from torch import Tensor
import torch.nn.functional as F
from typing import List
__all__ = ['downsample_labels', 'padded_stack2d', 'split_spatially', 'minibatch_std_layer', 'strided_upsampling2d',
'interpolate_vector', 'pad_to_div', 'pad_to_size', 'spatial_mean', 'process_scores', 'equal_size']... |
1092a5566b57e83d45034c0f7ea7867cc250fa65ed5d00198d8701be12135616 | Python | 8,097 | 196 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Assign an hexadecimal RGB color to one or more Trackvis (.trk) tractogram.
(If called with .tck, the output will always be .trk, because data_per_point
has no equivalent in tck file.)
Saves the RGB values in the data_per_point 'color' with values
(color_x, color_y, co... |
1a0a95d0000aa6f81d16d78e9f69cbe92430574b782fbe36b4a7882d680bd361 | Python | 8,097 | 196 | import os
import sys
import yaml
from pathlib import Path
import torch
import torch.nn as nn
import torch.distributed as dist
from torch.nn.parallel import DistributedDataParallel as DDP
from torch.distributed.elastic.multiprocessing.errors import record
from typing import Union
from .utils.dataset import get_TractCl... |
7e443b332ae62f460c970278465e2995878d97fe01289d69a39f7644e2a1e325 | Python | 8,098 | 236 | import numpy as np
import torch
import pickle as pkl
import os
import networkx as nx
from networkx.algorithms import tree
class MD17Dataset():
"""
MD17 Dataset
"""
def __init__(self, partition, max_samples, delta_frame, data_dir, molecule_type):
# setup a split, tentative setting
tr... |
c5f27c2751cbcd988982e6b621dea572631275f51481a8993907152a17b1e1b4 | Python | 8,099 | 324 | #!/usr/bin/env python
import os
import defopt
import logging
from pathlib import Path
import numpy as np
from typing import Optional
HUB = """
hub {sample}-FIRE-fiberseq
shortLabel {sample}-FIRE-fiberseq
longLabel {sample}-FIRE-fiberseq
genomesFile genomes.txt
email mvollger.edu
descriptionUrl fire-description.html
"... |
601e43d683053f2a85efa63af3e786d0beaf08c9d0603e8197dc4bd2b6a1807e | Python | 8,100 | 250 | #!/usr/bin/env python
"""
Handles communication with HAL.
Hazen 10/18
"""
import warnings
from PyQt5 import QtCore
# Debugging
import storm_control.sc_library.hdebug as hdebug
# Communication with the acquisition software
import storm_control.sc_library.tcpClient as tcpClient
import storm_control.sc_library.tcpMessa... |
ca090406a60278dcf936e9877ac876518afa06a3894511b42474cda5c7b8c72e | Python | 8,100 | 192 | # /------------------------------------------------------------------------------+
# | 21-OCT-2022 |
# | Copyright (c) Bone Imaging Laboratory |
# | All rights reserved ... |
e8a99c5574aa4edd61584a3be140c3481fd8f184adef511a2cb7720921ecf2a8 | Python | 8,104 | 239 | """
Module for plotting
Author: Bassel Arafat
"""
import numpy as np
import pandas as pd
from matplotlib.colors import to_rgb, ListedColormap
import matplotlib.pyplot as plt
import seaborn as sns
import ast
import torch as pt
import math
import Functional_Fusion.atlas_map as am
import SUITPy as suit
import fitz # Py... |
8cfc2197ea04a77e46fa5424fd2396c9a0a670b0793969d7cc33a505a1d4ad5e | Python | 8,108 | 195 | import os
import subprocess
import shutil
import nibabel as nib
import numpy as np
import pandas as pd
from nipype.interfaces.base import BaseInterface, BaseInterfaceInputSpec, TraitedSpec, File, Directory, traits, CommandLineInputSpec, File, TraitedSpec, CommandLine, Directory
from nipype.interfaces.utility import Ide... |
a5a165e58284b625ec9f975ab3cf8c2cebac8eb922475bedc7c803164bb4f700 | Python | 8,110 | 207 | """Tests for ADMET-AI."""
import pandas as pd
from pathlib import Path
from tempfile import TemporaryDirectory
import numpy as np
import pytest
from admet_ai import admet_predict, ADMETModel
from admet_ai.constants import DEFAULT_ADMET_PATH, DEFAULT_DRUGBANK_PATH
# Tolerances for comparing PyTorch predictions acros... |
8735a90d60d19eb12d22c666fd144d9cd8168c0c705ad32e479b4cfb59c52e2e | Python | 8,111 | 230 | # Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved
"""
Self-contained COCO JSON re-indexing function that creates temporary files.
"""
import json
import os
import tempfile
from pathlib import Path
from typing import Any, Dict, List, Optional, Tuple
def reindex_coco_to_temp(input_json_path: st... |
4c84551958689c9311d35938871f9384505ddbca0de3ec07f02b55d5ed0c55a4 | Python | 8,113 | 234 | import platform
from pathlib import Path
from typing import TypedDict, ClassVar, Literal, cast
from neuralib.typing import PathLike
from neuralib.util.utils import ensure_dir
__all__ = [
'RSCVP_CACHE_DIRECTORY',
'CONFIG_FOLDER',
'HISTOLOGY_HOME_ROOT',
#
'DISK_TYPE',
'DATA_SRC_TYPE',
#
... |
9806c51b30e872988c54b2c86abbabe36e3dce21636efa337876d7797b14e04a | Python | 8,113 | 293 | import arbor as A
from arbor import units as U
import functools
from functools import lru_cache as cache
from pathlib import Path
import subprocess
import inspect
# The API of `functools`'s caches went through a bunch of breaking changes from
# 3.6 to 3.9. Patch them up in a local `cache` function.
try:
cache(lamb... |
32f7472d2191ed2e6c439b30501a759e16e038cfbc0cef7d075e8781f889876c | Python | 8,116 | 246 | import pathlib
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QFileDialog, QMessageBox, QLabel, QLineEdit, QPushButton, \
QProgressBar, QStackedLayout, QSizePolicy
from PyQt5.QtCore import Qt, QTimer
from PyQt5.QtGui import QPainter, QPen, QColor
from lyroi.gui.utils import set_property_and_update
class Load... |
b3b79111da0c2421e58d3d65ae2a4f5485b245c220ce95c5446590e9efd643cd | Python | 8,119 | 248 | import logging
from collections import defaultdict
from pathlib import Path
from typing import Union, List
import numpy as np
import csv
import matplotlib
import math
# to enable %matplotlib inline if running in ipynb
from IPython import get_ipython
ipy = get_ipython()
if ipy is not None:
ipy.run_line_magic("ma... |
ca6c0c34573876889b85d5caa01d3f47b30a83a333bde6ed27bda783c9f41570 | Python | 8,123 | 232 | """Agent lifecycle management for the ChemGraph Streamlit UI."""
from typing import Optional, Sequence
import streamlit as st
def build_deepagent_options(
workflow_type: str,
workspace: Optional[str],
skill_dirs: Optional[Sequence[str]],
discover_skills: bool,
tool_names: Optional[Sequence[str]]... |
818edb4e9ddde5cf72ac34425d95c2ac3ea172a39045edd363c7a006f64b244a | Python | 8,124 | 142 | import functools
import torch
from brainscore_vision.model_helpers.activations import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_preprocess_images
from brainscore_core.supported_data_standards.brainio.s3 import load_weight_file
from PIL import Image
import numpy as np
import ti... |
49d21534a1fd0ba8cc93663d9c8fb0b090ebd69b22c0dfff39d7a48507add5c7 | Python | 8,127 | 223 | import SimpleITK as sitk
import numpy as np
import torch
import cv2
import tkinter as tk
from tkinter import messagebox
from PIL import Image, ImageTk
from torchmetrics import Dice, JaccardIndex
from monai.metrics import HausdorffDistanceMetric
import os
from display_gui import load_gt_nii
from faster_bootstrap import ... |
f94c7626ab8c909089ed9c5b6750ae032bbccd193a47fa5511832d1849ee2bc6 | Python | 8,127 | 235 | from typing import Optional, Tuple, Union
import torch
from torch import Tensor
from torch_geometric.utils import cumsum, scatter
try:
import torchmetrics # noqa
WITH_TORCHMETRICS = True
BaseMetric = torchmetrics.Metric
except Exception:
WITH_TORCHMETRICS = False
BaseMetric = torch.nn.Module # ... |
41ee7b578a931064fa345c15a7a2a1573020b6804351f6b4678bc346dccff067 | Python | 8,130 | 270 | from __future__ import absolute_import
from __future__ import division
import os, io
import errno
import codecs
import collections
import shutil
import sys
import json
import math
import numpy as np
import torch
import torch.nn as nn
import pyhocon
# import tensorflow.compat.v1 as tf
import pdb
def initialize_fr... |
6127a68b53ad369a97a008aa78a64f9de7a6f5c01385d216827686e3f7429b81 | Python | 8,132 | 176 | from torch.utils.data import Dataset
import torch
import os
from tqdm import tqdm
import pandas as pd
import numpy as np
import pickle
import time as t
class SpectrogramDataset(Dataset):
def __init__(self, root_path, spectrogram_dir_name, load_pair_same_speaker=False, n_first_freq=None, n_first_time=None):
... |
26a687eb27b03d58a26a85043d7d240345e300bd13f397ce7d4dfcbd40b043b7 | Python | 8,133 | 383 | #! /usr/bin/env python
# aponteeduardo@gmail.com
# copyright (C) 2016
''''
Likelihoods of the PROSA and SERIA models.
'''
import numpy as np
from tapas.sem.antisaccades.wrappers import *
def wrapper(llh, rt, ac, tt, theta):
rt = np.array(rt, dtype=np.float64)
rt = rt.reshape(rt.size)
ac = np.arra... |
a677e96cfa9636185dd382df6b35af8d66d4904d168b958b3720d4e371df7f95 | Python | 8,133 | 252 | from copy import deepcopy
from typing import Optional, Tuple
import matplotlib.pyplot as plt
from matplotlib.figure import Figure
from matplotlib.axes import Axes
import matplotlib.lines, matplotlib.patches
import numpy as np
from bread.data import Segmentation, Microscopy, Features, Ellipse, Contour, SegmentationFile
... |
1e912dcd511ee8bb26b0e1819422fffd8bbf2caa340a44b3f8e749960707cdf2 | Python | 8,136 | 218 | import jax
import jax.numpy as jnp
import matplotlib.pyplot as plt
import glob
import sys
import os
import re
import json
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
plt.rcParams["font.sans-serif"] = ["DejaVu Sans"] # Best available
plt.rcParams["font.family"] = "sans-serif"
plt.rcPa... |
acca41c4127ebaf7f467a6d32949e50898bfbc58425f35041b4990b130e8ed7b | Python | 8,136 | 227 | from typing import List, Tuple, Dict
import torch
import torch.nn.functional as F
from torch import Tensor
from skoots.lib.morphology import (
gauss_filter,
binary_dilation_2d,
_compute_zero_padding,
_get_binary_kernel3d,
)
@torch.jit.script
def average_baked_skeletons(baked_skeleton: Tensor, kernel... |
9a6d52e1bcd61dbbf95d575a2e3128c405a650598a52deadaf61cd28211c8baf | Python | 8,142 | 267 | from collections import deque, Counter
import warnings
import pandas as pd
import numpy as np
from xml.etree import ElementTree as ET
import math
import torch as th
BIOLOGICAL_PROCESS = 'GO:0008150'
MOLECULAR_FUNCTION = 'GO:0003674'
CELLULAR_COMPONENT = 'GO:0005575'
HAS_FUNCTION = 'http://mowl.borg/has_function'
FUNC... |
fee6dac7e76404f3bde2cebc832279b5a619207ef5ebeb2abd9385c8661d880b | Python | 8,144 | 207 | import pytest
import numpy as np
from comet import graph, utils
# Fixture to load data once for all tests
@pytest.fixture(scope="module")
def data():
"""
Keys: 'W', 'W_abs', 'W_bin', 'W_fix', 'W_len', 'W_norm', 'W_prop',
'avg_clustering_onella', 'avg_path_bin', 'avg_path_wei', 'dist_bin', 'dist_wei',
... |
3fbae38454b35ec426ed76d9850748082fcd946a4c2cc97a9bc69e7a8cad4666 | Python | 8,146 | 183 | #%% import libraries
%reload_ext autoreload
%autoreload 2
import os
from itertools import permutations, combinations, product
import time
import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)
import numpy as np
from functions import Get_paths, Get_trial
import f_pseudoPop
#%%
... |
451c84bb273597355cff8a97db3ea8220726c5dd2a3aa99967e2ed8680b222e0 | Python | 8,146 | 247 | from pathlib import Path
from typing import Any
import numpy as np
import pytest
import torch
from PIL import Image
from sklearn.preprocessing import StandardScaler
from eir.setup.input_setup_modules.setup_image import ImageNormalizationStats
from eir.train import Experiment
from eir.train_utils.evaluation_modules.ev... |
d273877ebf12614e5687cc1b2b7017cb4f6761d7ebef24f7b4bb5a40f0ec2ceb | Python | 8,146 | 247 | from pathlib import Path
from typing import Any
import numpy as np
import pytest
import torch
from PIL import Image
from sklearn.preprocessing import StandardScaler
from eir.setup.input_setup_modules.setup_image import ImageNormalizationStats
from eir.train import Experiment
from eir.train_utils.evaluation_modules.ev... |
4139df8e8e4d9fd47b5028ad27626ade6a9cad697d6ce1776a0deaed9e00f8e0 | Python | 8,147 | 193 | '''
This script will generate a matrix of pseudo image features from expression matrix.
A conda env is available in the project folder.
# input 1 : counts matrix, raw counts, sample by gene name
# input 2 : spot metadata, MUST have 'X','Y' columns.
# input 3 : output path, optional, default is ./intermediate
# input ... |
697c2b12aa6e9de14779d020519581051b7ad1b34a3c15e47953fb936ce81ed9 | Python | 8,147 | 199 | import torch
from utils import common_functions as c_f
from utils import loss_and_miner_utils as lmu
from miners.base_miner import BaseTupleMiner
class BatchEasyHardMiner(BaseTupleMiner):
HARD = "hard"
SEMIHARD = "semihard"
EASY = "easy"
ALL = "all"
all_batch_mining_strategies = [HARD, SEMIHARD, ... |
15e838ee6232a7df62d161c61746136c20bc9ffc8f56f51db923808390b16a6b | Python | 8,148 | 226 | """Data reading utils."""
import json
import numpy as np
import pandas as pd
from scipy import sparse
from texttable import Texttable
from sklearn.decomposition import TruncatedSVD
from sklearn.metrics import roc_auc_score, f1_score
from torch import Tensor
import torch
from collections import Counter
import random
... |
432def13bfaf706864d0ce979691d774fbd9c6d3282d0d22082c586643a4fdb7 | Python | 8,153 | 189 | import torch
import torch.nn as nn
from torch.nn.functional import softmax
from typing import Optional, Union, List, Type, Dict
from torch import Tensor
from torch.nn import functional as F
from functools import partial
from ..util.util import lookup_nn, dict2model
from .unet import UNet, IntermediateUNetBlock
from .co... |
d05df6a87e1a0d3fc4a7a1041cdf366e2b7f9088a256fd801046355632912ce4 | Python | 8,155 | 248 | import functools
import inspect
import logging
import os.path as op
from time import time
import nibabel as nib
from dipy.io.stateful_tractogram import StatefulTractogram
from dipy.io.streamline import save_tractogram
try:
from trx.io import save as save_trx
from trx.trx_file_memmap import TrxFile
has_tr... |
d05eaadf5cc6f52301dbb7429d36bc6ec727b5ff1aacd0396c4f3011f44a8e9b | Python | 8,155 | 265 | """
(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, software
... |
c964481d5ec02aaef33dbb545f92e9dd21635f6861ce7810532fbfe0e2d8a27b | Python | 8,157 | 243 | """
Lists of supported models for different LLM providers.
"""
# OpenAI models that are supported
supported_openai_models = [
"gpt-5-mini",
"gpt-5-nano",
"gpt-5.1",
"gpt-5",
"gpt-4o-mini",
"gpt-4o",
"gpt-4.1",
"gpt-3.5-turbo-0125",
]
# Ollama models that are supported
supported_ollama_m... |
74e7504b7b5b21cbc3cadcd4de6c65dc242a79035e7111f609eb75ba06708395 | Python | 8,158 | 258 | from collections import defaultdict
import numpy as np
from numba import njit, prange
from scipy.spatial import cKDTree
from .utils import util
#region Cylinder particle packing simulation
def sample_free_particles_in_cylinder(N, R, L):
r = R * np.sqrt(np.random.rand(N))
theta = 2 * 3.1415926 * np.random.ran... |
f3ffc142f6b161fe9b07e024c6ef09aac05714405b587efce17cbfaf10c61882 | Python | 8,158 | 258 | # %%
import os
import glob
import random
from os import listdir, makedirs
from os.path import join, exists, isfile, isdir, basename
from tqdm import tqdm, trange
from copy import deepcopy
from time import time
import numpy as np
import torch
from torch._dynamo import OptimizedModule
from torch import multiprocessing as... |
114b3828e712a80549277a93371afc67cf793cc8beeb77ae046206c9e8739388 | Python | 8,161 | 179 |
import sys
import torch
import logging
import numpy as np
from tqdm import tqdm
import multiprocessing
from datetime import datetime
import torchvision.transforms as T
import test
import util
import parser
import commons
import cosface_loss
import augmentations
from cosplace_model import cosplace_network
from dataset... |
e258def88470075f9542b8844a33c530f72d52b40762fd1671f06d6eeea28a23 | Python | 8,164 | 203 | import sys
sys.path.append('..')
from functools import partial
import torch
from torch.utils.data import Dataset
from torch.utils.data import DataLoader
import dgl
from esm import pretrained
import numpy as np
from common.sampling import sample_khop
embedding_model = None
batch_converter = None
AMINO_ACIDS = ['A','R',... |
e748a6e674d66c8c859c1317e9dca811bb2b3dcacc8568638a4b9ef239c991b9 | Python | 8,165 | 284 | #!/usr/bin/env python
# Copyright 2017 Calico 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 ... |
80ce739d65769973c1e8a73bb7ba239e9662ad37c03621d876755b852b301a5a | Python | 8,169 | 167 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
from __future__ import annotations
from pathlib import Path
from ultralytics.utils import LOGGER, QNN_HTP_TARGETS, WINDOWS
from ultralytics.utils.checks import check_requirements
def qnn_library_paths() -> tuple[str | None, str]:
"""Resolve th... |
8a60c0e7181d0a07a31375f5d1fa66120911accf59b5f3a4f17183f219b612ac | Python | 8,169 | 186 | """Nested leave-one-subject-out cross-validation.
Outer loop: one participant is held out entirely -- no window from that
participant reaches training, scaling, imputation, hyperparameter selection, or
threshold selection.
Inner loop: grouped k-fold over the *training* participants only, used for both
hyperparameter ... |
fd155b473d9e92bde7960f8d75c0f0b6026ca212a7dfe383afff93dadda79c1a | Python | 8,170 | 242 | """Use CONCH to extract latent features from whole slide images."""
from __future__ import annotations
import argparse
from pathlib import Path
from typing import Callable, List, Optional, Sequence, Tuple, Union
import h5py
import numpy as np
import openslide
import torch
from PIL import Image
from torch.utils.data i... |
6b9be3861ce3daf3896af4ea23cde769d1637e0ecab8180324d0e129d64b79c6 | Python | 8,172 | 148 | import os
from pathlib import Path
import pickle
import json
import numpy as np
import xarray as xr
import pandas as pd
from brainscore_core.supported_data_standards.brainio.assemblies import NeuronRecordingAssembly
from brainscore_core.supported_data_standards.brainio.stimuli import StimulusSet
from brainscore_core.... |
a9bd5920e65d083e6b7cdc1b0128fe92c2d29efa45d47f904ee9190d0272c10c | Python | 8,175 | 189 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Script to estimate asymmetric ODFs (aODFs) from a spherical harmonics image.
Two methods are available:
* Unified filtering [1] combines four asymmetric filtering methods into
a single equation and relies on a combination of four gaussian filters.
* Cosi... |
cb301f2437bdb1051e394c34759493c38b5ec7d632784aefed4d1393fcf1e4fc | Python | 8,176 | 216 | import argparse
import os
import os.path as osp
import time
import numpy as np
import torch
import torch.nn.functional as F
from sklearn.metrics import f1_score
import pandas
import json
import torch_geometric.transforms as T
from tqdm import tqdm
import spacy
import re
import ijson
from vaderSentiment.vaderSentiment i... |
8d6b30a9d2efc0fcfe54638440f992392cc338da33919cc2d04d80bbeb639bdc | Python | 8,179 | 144 | # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'nstorm-misc.ui'
#
# Created by: PyQt5 UI code generator 5.7
#
# 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.setObjec... |
d9f6cf2cbf793c300628eff52baec91d9a7d9b9c1c4294c7455e11bad805b1c2 | Python | 8,179 | 247 | """
VTK read/write filters for FreeSurfer geometry files.
"""
# Author: Oualid Benkarim <oualid.benkarim@mcgill.ca>
# License: BSD 3 clause
import re
import numpy as np
from vtk import vtkPolyData
from vtk.util.vtkAlgorithm import VTKPythonAlgorithmBase
from ..checks import has_only_triangle
from ..decorators impo... |
0dcb6d97594cac5eec0af81b6da073c2d2b566658f006d78ac84795f7031bb19 | Python | 8,183 | 231 | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import tensorflow as tf
from sklearn.metrics import (confusion_matrix, roc_auc_score, precision_recall_curve, roc_curve, auc as sk_auc, precision_score, recall_score, matthews_corrcoef, fbeta_score)
import seaborn as sns
from config.paths import FIG... |
26dbd02dd2701e00f11d7e4b41491fca6f6a79f5e49d94f1b37703fde1c1a484 | Python | 8,185 | 190 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
from __future__ import annotations
from pathlib import Path
from typing import Any
import numpy as np
import torch
import torch.distributed as dist
import torch.nn.functional as F
from PIL import Image
from ultralytics.data.dataset import SemanticD... |
487e950be6168d864fa1c6d46e785e4b66fe176e7a96d3019b306794b5831d49 | Python | 8,185 | 228 | """
Neural network models for batch alignment.
Adapted from the original models.py with lazy imports.
"""
import logging
logger = logging.getLogger(__name__)
def _get_torch_modules():
"""Lazy import torch modules when needed."""
import torch
import torch.nn as nn
return torch, nn
class Autoencoder... |
5050993d753bdb9c88dd8b04127a36884fef5f440b469298fda2dfe6b0e63a08 | Python | 8,188 | 215 | """
Multiclass
from:
https://github.com/guillaumegenthial/tf_metrics/blob/master/tf_metrics/__init__.py
"""
__author__ = "Guillaume Genthial"
import numpy as np
import tensorflow as tf
from tensorflow.python.ops.metrics_impl import _streaming_confusion_matrix
def precision(labels, predictions, num_classes, pos_in... |
a150ecbee8100034d403397f4f8da67c21721e199ff8f2c482a73feb17eed123 | Python | 8,188 | 227 | # This code is derived from the gammatone toolkit, licensed under the 3-clause
# BSD license: https://github.com/detly/gammatone/blob/master/COPYING
"""Represent waveforms with spectrograms using the Fast Fourier Transform."""
from __future__ import division
import numpy as np
from .filters import erb_space, make_er... |
ef36205fbe8dc48807c21b43a63529a0b39b7d382d900a4d52a9baf9bdea0765 | Python | 8,188 | 251 | from psychopy import core, event, visual, monitors
import os
import pandas as pd
from const import (
FULLSCREEN,
START_KEY,
TRIGGER_KEY,
CYCLES_PER_DEGREE,
OBJECTS_DIR,
SCRAMBLED_DIR,
OBJECT_SIZE,
FIXATION_TIME,
IMAGE_TYPE,
STIM_ON_TIME,
STIM_OFF_TIME,
STIM_PRES,
FLIC... |
88f15790a9d338433e1f6313e0f2c71ef069b6797d94ed38e465e0c61f3a85f7 | Python | 8,189 | 262 | """
Utilities for the Batch Alignment CLI.
Includes logging setup, dependency checks, and helper functions.
"""
import logging
import sys
import time
from pathlib import Path
from typing import Optional, List
import importlib
import tempfile
import os
def setup_logging(level: str = "INFO", log_file: Optional[str] = ... |
5e136b53dd6cdc096a4517ca4897d0e288e50c01e6790aab24d6aa07a1a3a562 | Python | 8,191 | 224 | """ Dataset Factory
Hacked together by / Copyright 2021, Ross Wightman
"""
import os
from typing import Optional
from torchvision.datasets import CIFAR100, CIFAR10, MNIST, KMNIST, FashionMNIST, ImageFolder
try:
from torchvision.datasets import Places365
has_places365 = True
except ImportError:
has_places3... |
c77ca846979cf6a1f5b4f5ba86bf79b399385ee1c04f254a7f6ab040f0e551b3 | Python | 8,192 | 233 | import reprlib
import typing
from collections import OrderedDict
from collections.abc import Sequence
from copy import deepcopy
from pathlib import Path
from typing import Any
import torch
from eir.models.model_setup_modules.meta_setup import al_meta_model
from eir.utils.logging import get_logger
logger = get_logger... |
66055316841384e9361af136579043114a0ea9083b660d38499b8e43571cf4bd | Python | 8,193 | 288 | #!/usr/bin/env python3
import arbor as A
from arbor import units as U
import argparse
import numpy as np
from numpy.random import RandomState
"""
A Brunel network consists of nexc excitatory LIF neurons and ninh inhibitory
LIF neurons. Each neuron in the network receives in_degree_prop * nexc
excitatory connections c... |
8be738dea09eb84cdde08d2aa2bcff1134d70f942e3f9bf132f5945dee494673 | Python | 8,193 | 218 | # Copyright (C) 2021-2022 Intel Corporation
# Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
from http import HTTPStatus
from typing import ClassVar
import pytest
from cvat_sdk.api_client.api_client import ApiClient, Endpoint
from cvat_sdk.api_client.exceptions import ForbiddenException
from deepd... |
9fa24851ff25b6f09cb06fa62aed1d07fa9cb6aa340c79d6467b3bdfdd4508cd | Python | 8,194 | 216 | import warnings
import cv2
import numpy as np
import torch
from kornia.color import rgb_to_grayscale
from packaging import version
try:
import pycolmap
except ImportError:
pycolmap = None
from .utils import Extractor
def filter_dog_point(points, scales, angles, image_shape, nms_radius, scores=None):
h,... |
057b780dbebe6468db7ff33015ac524280a9ecddae6447ba69d26fb0fa1aca25 | Python | 8,195 | 277 | import textwrap
from collections.abc import Sequence
from functools import partial
from pathlib import Path
import matplotlib.pyplot as plt
from PIL import Image
from docs.doc_modules.c_sequence_outputs.utils import get_content_root
from docs.doc_modules.experiments import AutoDocExperimentInfo, run_capture_and_save
... |
f33c73041a7a14774d8192436f0ff043bfc0e800d22d37458a2f5efbe887159c | Python | 8,198 | 218 | import pathlib
import numpy as np
import matplotlib
matplotlib.use('Qt5Agg')
from matplotlib import pyplot as plt
from helper_functions.get_dendritic_current import NANO_FACTOR
from neuron_interface.neurosim.cells import L5_TTPC2_cADpyr
from neuron_interface.neurosim.simulation.dendritic_delay_simulation import Dendrit... |
1961d5a6550e0f82c49925eccdd592036fe73ca58bec31f311ffb0acdf9be59c | Python | 8,200 | 207 | from PySide6.QtWidgets import QInputDialog, QDialog, QDialogButtonBox
from bannotator.ui import *
import re
class TruncateAnnotationDialog(QDialog, Ui_TruncateAnnotationDialog):
def __init__(self, annot_length, vid_length, *arg, **kwarg):
super().__init__(*arg, **kwarg)
self.setupUi(self)
... |
c0adf84cbb05c75e6748e478b272232e66ae0d8d5aeb77934f1028f4bb497ecc | Python | 8,200 | 174 | """ parsing arguments to regression.py """
import argparse
def get_parser():
parser = argparse.ArgumentParser(fromfile_prefix_chars='@')
# defining the dataset and network to train
parser.add_argument("--dataset_name",
help="Name of the dataset to train on. if not given, then th... |
f7408393a38fad8b8e38e541c70d7cb10db8a9b18dacfe0ac94007129c99efbe | Python | 8,200 | 247 | #!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Connect to a PI stage using the E873 controller and the Q-545.140 translation stages
using Physik Instrumente (PI) GmbH & Co. KG
sc_hardware.physikInstrumente.E873.py
Alistair Boettiger, April 2019
V1.1
Functional connection to x-y axes of PI piezo stage
V1.2... |
17849d17519a6461ca621957333b2c243a1d715ee1381397eaf6de227c65b823 | Python | 8,202 | 244 | #!/usr/bin/python
#
## @file
#
# Custom editor for illumination power buttons.
#
# Hazen 05/16
#
from operator import itemgetter
from PyQt5 import QtCore, QtGui, QtWidgets
import storm_control.sc_library.hdebug as hdebug
import storm_control.hal4000.settings.parametersEditors as parametersEditors
import storm_contro... |
aeab70f469435bada4618dbd3a3de48e35ff2c198f810e43f07591b578812a85 | Python | 8,210 | 243 | import numpy as np
from scipy.optimize import linear_sum_assignment
from scipy.sparse import csr_matrix
from bottleneck import nanmean
from bottleneck import median as bnmedian
from numba import jit, njit, prange # jit compilation
from copy import copy
import pickle
from scipy.sparse import csr_matrix, hst... |
a00fe9c57243a21677025b337cf5f5897942fcaa5614491f18c0207639a5c5ea | Python | 8,212 | 198 | from typing import Any, Dict, List, Optional
from brainglobe_atlasapi.structure_class import StructuresDict
from qtpy.QtCore import QAbstractItemModel, QModelIndex, Qt
from treelib import Node
class StructureTreeModel(QAbstractItemModel):
"""A Qt item model for displaying a treelib structure tree."""
def __... |
64e4fe4ee83d59581d26ebdf8fe68e56c096052fdbdf52bec121735f9c37130d | Python | 8,218 | 237 | # coding=utf-8
from typing import List, Optional, Tuple, Union
import tensorflow as tf
import tensorflow.keras.layers as tfkl
from deepreg.model import layer
from deepreg.model.backbone.u_net import UNet
from deepreg.model.layer import Extraction
from deepreg.registry import REGISTRY
class AdditiveUpsampling(tfkl.... |
b5d19547ca3884fa5e18efe236405a0304b4b6f0984f63a74e8786536d5e5b94 | Python | 8,218 | 218 | from typing import Final, Optional, Tuple
import torch
from torch import Tensor
from torch_geometric.experimental import disable_dynamic_shapes
from torch_geometric.utils import scatter, segment, to_dense_batch
class Aggregation(torch.nn.Module):
r"""An abstract base class for implementing custom aggregations.
... |
dd8831f53344315d676e4123f656055b558873492d6b4e8cff1f0f5e42a4255c | Python | 8,218 | 154 | """
DyNeMo: Selecting a Run
=======================
Training DyNeMo several times on the same data can give different networks: the modes come out in a different order and, where the data do not constrain the solution well, some networks can be split or combined differently from run to run. A good default is to analys... |
8ef2b57807ab2e6134092b28a2d7f9a7bac796411a9675f660cf9457cdb060fd | Python | 8,223 | 203 | import os
import torch
from nets.deeplabv3_training import (CE_Loss, Dice_loss, Focal_Loss, lseg_loss,
weights_init)
from tqdm import tqdm
from utils.utils import get_lr
from utils.utils_metrics import f_score
def fit_one_epoch(model_train, model, loss_history, eval_callback, op... |
0a773f13ef55fa910b70cbdce0c3732e2e5ecba1b5a8b5203da4ce7678a1edb5 | Python | 8,224 | 214 | from argparse import ArgumentParser
from dataset import SATARDataset
import numpy as np
import time
import torch
import torch.nn as nn
from torch.utils.data import DataLoader
from model import SATAR, BotClassifier
from tqdm import tqdm
from utils import null_metrics, calc_metrics, is_better
device = torch.device('cuda... |
7eeaba4e4abc674a16e504b1b319a90f14a7569b53d505ab9264e514e51ed5d3 | Python | 8,224 | 218 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import unittest
from datetime import datetime, timedelta, timezone
from django.contrib.auth import get_user_model
from django.test import RequestFactory
from cvat.apps.events.const import MAX_EVENT_DURATION, WORKING_TIME_RESOLUTION
from cvat.apps.e... |
3b04d61e221d06c3d572657109eaaf4cf1c80f64cc7581a95670d62807695cd2 | Python | 8,229 | 247 | import numpy as np
from scipy.stats import ttest_rel, ttest_1samp, ttest_ind, kstest, wilcoxon, pearsonr, spearmanr
from statsmodels.stats.multitest import fdrcorrection
import pickle
import mne
import pandas as pd
import glob
import os
from update_sub_lists import*
from pp_utils import *
### T-test utils ###
def g... |
9184cff0ae20139f78321ccb4bca8db7b9f80275978edda515b75d76d0f064d7 | Python | 8,231 | 200 | import os
import numpy as np
import pandas as pd
from tqdm import tqdm
import mne
from sklearn.metrics import roc_auc_score, average_precision_score, roc_curve, precision_recall_curve, confusion_matrix, cohen_kappa_score, f1_score
import matplotlib.pyplot as plt
plt.rcParams.update({'font.size': 14})
import sea... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.