sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
1e3c88f770648c71cd08eb942fd0dc799f6f0f7c0b3d1db19501656ff592afa0 | Python | 16,424 | 350 | import logging
from collections import OrderedDict
import numpy as np
from numpy.random.mtrand import RandomState
from scipy.interpolate import interp1d
from scipy.optimize import fsolve
from scipy.stats import spearmanr
from tqdm import tqdm
from brainscore_core.supported_data_standards.brainio.assemblies import wal... |
553bf87835bc39d4954c9841855b99191118d1f1f6d04a15e2c2875dff972d5d | Python | 16,426 | 371 | #!/usr/bin/python
# ----------------------------------------------------------------------------------------
# A class to load and parse predefined pump commands.
# ----------------------------------------------------------------------------------------
# Jeff Moffitt
# 2/16/14
# jeffmoffitt@gmail.com
# --------------... |
3d4f68bd1774f8c43515887abfe0f7aaf15acf5be4232ebd2dcd7e28afbb2809 | Python | 16,435 | 384 | """Load suite2p output files into numpy arrays."""
from dataclasses import dataclass, field
from pathlib import Path
import numpy as np
from meanap.pipeline.atomic import atomic_savez
class Suite2pOutputMismatch(ValueError):
"""``iscell.npy`` describes a different ROI list from ``F.npy``/``stat.npy``.
Not... |
6b18a0d498d482cd5ace642165431fce476498bb50edf62eaeaf594bd850ff86 | Python | 16,439 | 449 | # Copyright (c) Facebook, 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 math
import torch
import torch.nn as nn
import torch.nn.functional as F
from .modules import (
TransformerLayer,
AxialTransfo... |
efa4cbd3f76d97aa40f38b0d8b1bdeb467ff66c6a943d5ece39873318b822518 | Python | 16,439 | 494 | #!/usr/bin/python
#
## @file
#
# Handles viewing the mosaic.
#
# Hazen 06/14
#
import os
from PyQt5 import QtCore, QtGui, QtWidgets
import storm_control.steve.qtMultifieldView as multiView
import storm_control.steve.coord as coord
## createGrid
#
# Create a grid position array.
#
# @param nx Size of the grid in x.
... |
2db1e1a5e50305de202487d59fc2f56fdbe198bb7cd62b9fe65b2a4b138d8adb | Python | 16,442 | 336 |
import dtiplayground.dmri.preprocessing as prep
import yaml
from pathlib import Path
import dtiplayground.dmri.common.tools as tools
from dtiplayground.dmri.common import measure_time
import shutil
import os
import markdown
import pandas
### utilities
def find_fsl(lookup_dirs=[]):
fsldir=os.environ.get... |
48d8f5ccc1410f6cbd1a10949573252be6ff29a4573a0e0d3bd521e798fe6df7 | Python | 16,447 | 416 | #%% Imports
import pandas as pd
import numpy as np
import re
from pathlib import Path
from datetime import datetime
from sklearn.metrics import confusion_matrix
from config.config import settings
from data.preprocessing import run_full_cleaned_data_no_encoding
#%% Functions and definitions
TIME_FORMAT = "%Y/%m/%d... |
aeb8d2e3b9f713ca42ce47c9679f1aed1bb33c068fe4c7007a70af4f956cbb67 | Python | 16,449 | 455 | import warnings
import torch
import torch.nn.functional as F
from scipy import signal
from featurevis.utils import varargin
################################## REGULARIZERS ##########################################
class TotalVariation():
""" Total variation regularization.
Arguments:
weight (float... |
b9ab490d9941cb6cbd39a2a89d737f4655e4c3292ec17a11fa7b5364a3991578 | Python | 16,449 | 499 | import multiprocessing
from collections.abc import Callable
from dataclasses import dataclass
from pathlib import Path
from typing import TYPE_CHECKING
import torch
import torch.multiprocessing
from eir.models.models_utils import log_model, prepare_example_batch_for_torchview
from eir.train_utils.accelerator import s... |
673ecf9589fd20b5ba124d924c8f0014b3e0fd91bbb7980368ab8ea3d391fbf8 | Python | 16,451 | 471 | #!/usr/bin/env python
"""
The messages that are passed between modules.
Hazen 01/17
"""
import traceback
import types
from PyQt5 import QtCore
import storm_control.sc_library.halExceptions as halExceptions
import storm_control.sc_library.hdebug as hdebug
import storm_control.sc_library.parameters as params
import ... |
870532ce5339797f62a6ffcd7b0c16f57cd57afd101c3b33c41606f1b2a6270e | Python | 16,452 | 451 | # -*- coding:utf-8 -*-
from __future__ import print_function, division
from future_builtins import zip
try:
range = xrange
except NameError:
pass
import glob
import numbers
import contextlib
import functools
import os
import math
import operator
import copy
from collections import namedtuple
i... |
8fd460fd129143fb475be3337ff0b1ba431a89375633a1d3948223f7b8e1885f | Python | 16,453 | 379 | from ast import Raise
import torch
import random
import time
from sklearn.metrics.pairwise import cosine_similarity, pairwise_distances
import copy
from tqdm import tqdm
from .model import cats_net
def get_optimizer(net, optimizer_type, lr, momentum, wd, fix_ts = False):
if fix_ts:
param_list = [param for ... |
096a8a919e0cef9e62743d7221f890d92242196d35105389f5b9632bfd404a23 | Python | 16,456 | 432 | """
This file contains helper functions for behavior plots.
"""
import sys
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import statsmodels.formula.api as smf
import matplotlib.pyplot as plt
from utils.get_session_info import find_behavior_sessions
from copy import deepcopy
im... |
5fd1e7be2b5edb8e5e0c650fc40ab8ad85a663008c2117af4da5b24f39d5f491 | Python | 16,457 | 464 | """
Production-ready EBM predictor with built-in schema validation.
This module provides a wrapper around the EBM model that automatically
validates input data before making predictions.
"""
import pickle
from pathlib import Path
from typing import Any, Optional, Tuple, Union
import numpy as np
import pandas as pd
f... |
c8353150aa3dde06c7dd2b480522cc5d0c17b3d2955a0de73a140c81fb60aa02 | Python | 16,462 | 355 | import abc
import warnings
from typing import Type
import pandas as pd
import numpy as np
import statsmodels.api as sm
from sklearn.preprocessing import MinMaxScaler, OneHotEncoder
from sklearn.utils.multiclass import type_of_target
from .doubly_robust import BaseDoublyRobust
from causallib.estimation.base_estimator ... |
75afd7bc4c0d36bdd05e73b63dc44de2ad6d61da935527aec833113b3bcd6224 | Python | 16,469 | 455 | # 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
import torch.nn as nn
import torch.nn.functional as F
from typing import Optional, Tuple, Type
from .common... |
e28104eca619db44f41d319a26fab32d69c3c862331d5d6453ee5c4bffe39324 | Python | 16,470 | 281 | # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file '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.setObjectNa... |
8a949c393a9642e755e2064ecfa25240f6685ace67e5bb272d80840f48007917 | Python | 16,478 | 356 | import shutil
from pathlib import Path
from typing import List, Optional, Union
from loguru import logger
from brainles_preprocessing.brain_extraction.brain_extractor import BrainExtractor
from brainles_preprocessing.constants import Atlas, PreprocessorSteps
from brainles_preprocessing.defacing import Defacer, Quicks... |
48813cd7e2c719df3ff912034b1a66bd996376a5bc3c1c98910e8fcdd92ec0e2 | Python | 16,479 | 493 | """Focused tests for the TensorFlow backend fit loop.
These tests are intentionally narrow. Each one targets one contract of the
current TF fitting path so that regressions are easy to localize:
- accepted input container types
- fitter-option behavior around validation
- inclusion of layer-added regularization losse... |
2d00cd4ff302ffad864af64cee256def849d6dd2fdcea521dc6a326e73f9728f | Python | 16,486 | 565 | #!/usr/bin/env python
# -*- coding : utf-8 -*-
"""Utilities for extracting information on various input files using
MRtrix3's mrinfo tool. All values are returned in basic Python data
types.
"""
import os.path as op
import re
import subprocess
from typing import List, Tuple, Union
def getconsole(path: int, flag: st... |
f80116ff5a548a0d9af0eafc51f977189da0ffd218beca2f347d3d74a9c08fb0 | Python | 16,488 | 527 | from sklearn.preprocessing import normalize
from sklearn.cluster import DBSCAN, OPTICS
from skimage.filters.thresholding import threshold_otsu
from statsmodels.stats.multitest import fdrcorrection
from scipy.stats import mannwhitneyu
from scipy.spatial import Delaunay
try:
from scipy.sparse import csc_array
except... |
99300361b199e8e07d3733a55841cdc83ab2d0cb419759ceb1bb47f910f83226 | Python | 16,490 | 433 | import sys
sys.path.insert(0, '../')
sys.path.insert(0, '../../')
sys.path.insert(0, '../../../')
sys.path.insert(0, '../../../ogb')
import argparse
import os
from shutil import copy
import time
import torch
import torch.nn.functional as F
from torch.utils.data import DataLoader
import torch_geometric.transforms as T... |
69bb5b365d803ed4a2948f5ccaf9cd56924caaeeadd6717917b80dafd1cee3a5 | Python | 16,492 | 311 |
import dtiplayground.dmri.preprocessing as prep
import dtiplayground.dmri.common.tools as tools
from dtiplayground.dmri.common.dwi import DWI
import yaml
from pathlib import Path
import importlib
###
import numpy as np
import nibabel
class BRAIN_Mask(prep.modules.DTIPrepModule):
def __init__(self,config_dir,*arg... |
f66e98fc5651b4ec4ee4f6bc1110b843ab26c83d54b87d695d23fd9938c5f604 | Python | 16,500 | 496 | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
# ---------------------------------------------------------------
# coding=utf-8
# Copyright 2020 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "Licens... |
8a34cbe54d28216988ebdde7857184d4cb6b06dbdac1b44cdbe5fb53f28397a9 | Python | 16,508 | 303 | """Synthetic-data regression tests: never inspect the author's image collection."""
import csv
import gzip
import hashlib
import io
import json
import tempfile
import unittest
import zipfile
from pathlib import Path
from PIL import Image
from openplant.rebuild import (REQUIRED_FIELDS, ensure_disjoint, iter_manifest,
... |
b35d7603ff1c5a39916a8ca264a7ffcf916395cf128aa71cc9fc2613b601ed6a | Python | 16,509 | 403 | import os
import yaml
import h5py
import sys
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from scipy.stats import kendalltau,pearsonr
import pandas as pd
pathpath,run1,run2,stag1,stag2,ncluststr,cmethod,roi_tag,thistag,reftag = sys.argv[1:]
'''
run1 = 'runC00dMP3_brain'
run2 = 'runIBL... |
a960ea84e2b2b5f858b60e64c05555601b5ee23a0c253ffa0f29ceebb09c07c1 | Python | 16,511 | 393 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This script filters streamlines in a tractogram according to their geometrical
properties (i.e. limiting their length and looping angle) and their anatomical
ending properties (i.e. the anatomical tissue or region their endpoints lie
in).
See also:
- scil_tracto... |
6c0985b953b0961883226eae5b5b0653079c48a45484765a96d800fbd4775e80 | Python | 16,513 | 417 | '''
Author: Laurent Guerard
Group: IMCF
Email: laurent.guerard@unibas.ch
Creation Date: Wednesday, 16th October 2019 3:35:12 pm
-----
Last Modified: Wednesday, 13th November 2019 16:36:52
Modified By: Laurent Guerard
-----
HISTORY:
Date By Comments
---------- -- -------------------------------... |
a4d592b645857a2181f75ea9e339fef38890f89b9c2bb26de8f0fb7d91be78c3 | Python | 16,516 | 500 | import logging
import math
import tempfile
from math import radians
import imageio
import numpy as np
from dipy.align import vector_fields as vfu
from dipy.align.imwarp import DiffeomorphicMap, mult_aff
from dipy.reconst.gqi import squared_radial_component
from dipy.tracking.streamline import set_number_of_points
from... |
3be987c063f882a8440e2cec5fef7d771a81fd75c248ff4f1162849ee157fc8c | Python | 16,519 | 479 | """Atomistic LIne Graph Neural Network.
A prototype crystal line graph network dgl implementation.
"""
from typing import Tuple, Union
import dgl
import dgl.function as fn
import numpy as np
import torch
from dgl.nn import AvgPooling
# from dgl.nn.functional import edge_softmax
try:
from pydantic.typing import L... |
ba9157f61785b8e4fc0bd9b00cfe0c34c10d8944d726d00ae52c4c012bedd43c | Python | 16,521 | 443 | # 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, ... |
973d2aa6d95d122e9ea5cf1ed20cd86186c04672dc50a274d2fee0884ef3c69a | Python | 16,522 | 443 | import torch
import numpy as np
import scipy.stats as stats
from .utils import sample_dist
from typing import Literal
image_size = 224
visual_degrees = 7
ppd = (image_size/visual_degrees)
kernel_size = {'p': 21, 'm': 65} # 95% of Gaussian coverage
# Receptive fields of P and M ganglion cells across the ... |
1a70ac6f16a0ab3ef19ac0218c9bd4ab596ec2df23c297f9366e2c117a15374a | Python | 16,523 | 468 | #!/usr/bin/env python
"""
Communicates with the National Instrument card(s).
Hazen 4/17
"""
import ctypes
import numpy
import time
import traceback
import threading
import PyDAQmx
import storm_control.sc_library.halExceptions as halExceptions
timeout = 1.0
def getLock():
return threading... |
8444d546f96f7827d32c346200ea71c6ddd1b9c0fb5b1e86d78c41d4fbd4b06a | Python | 16,550 | 439 | import importlib
import sys
import copy
import numpy as np
import random
import matplotlib.pylab as plt
import pandas as pd
from tqdm import tqdm
import load_bhv as lb
importlib.reload(lb)
import copy
import uuid
class MDP():
def __init__(self, n_states_per_step, acts, set_prob_option, state_reward, goal_steps=Non... |
e51e588b1d9b11fe7d8aff8ec8951014712fa3cf752539e792080151f14bf6c6 | Python | 16,554 | 378 | import sys
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle
from PIL import Image
import numpy as np
from .internals import *
from .components import __get_figax
from typing import Union, Any, Dict
# grab module
__pub = sys.modules['pubplot']
def directed(nodes: Dict[str, t... |
f0c5e86eea586a4500fe0061661a7f4f3d2687ceebf68c06342d69741b7c9630 | Python | 16,556 | 554 | import copy
import torch
import random
import networkx as nx
import matplotlib as mpl
import numpy as np
import scipy.sparse as sp
from rdkit import Chem
from rdkit.Chem import rdDepictor
from torch_geometric.loader import DataLoader
from torch.quasirandom import SobolEngine
from networkx.drawing.nx_pydot im... |
02bfc0ae4d568c83832409485633678605237147825628561e369e7c98b6a5f2 | Python | 16,566 | 465 | #CORRELATION FUNCTIONS
#1) MATLAB-STYLE CALCULATION of XCORR
#2) CORRSHIFT - ANALYSIS
#3) PLOTTING
#4) TRCCs
###--> please refer to doof>29_saveTheThetaShift.py for usage instructions
import numpy as np
import matplotlib.pyplot as plt
import scipy.fftpack
def nextpow2(x):
return np.ceil(np.log2(np.abs(x)))
... |
62f1ddecc53d1ce97b60f524b0fb6e3eaa4722423562da331033dcae11d488aa | Python | 16,575 | 359 | #!/usr/bin/env python
"""
Handles all interaction / communication with the parameters widget.
This widget is responsible for keeping track of the various
different parameter files that the user has loaded as well as
editting and saving these parameters.
Unlike in Python2/PyQt4 HAL there is no longer a single current ... |
b34d03d34039a807a90077e63f2c417aefa889dd0a32c1ad2002e52886101a72 | Python | 16,576 | 395 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
import sys
from collections import OrderedDict
from pathlib import Path
from types import SimpleNamespace
from unittest import mock
import pytest
import torch
from tests import MODEL, SOURCE, TASK_MODEL_DATA
from ultralytics import YOLO
from ultraly... |
f3d1411e0d1ddf8d488f21d84b6d6791d2fdf191c15459780d77b13240263c7e | Python | 16,583 | 268 | # from mpi4py import MPI
import mpi4py
# mpiexec -n 3 -f machinefile_mp python3 main_mpi.py
import pickle
import logging
from zigzag.classes.opt.spatial.generator import UserSpatialMappingGenerator
from zigzag.classes.stages.Stage import Stage
from zigzag.classes.stages.SpatialMappingConversionStage import (
Spat... |
6682226bfefa8052684a68fca9eb0327db7ab1ba44e6668a3598b8d3e5c62274 | Python | 16,588 | 396 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
# Tests Ultralytics Solutions: https://docs.ultralytics.com/solutions,
# Includes all solutions except DistanceCalculation and the Security Alarm System.
import os
from unittest.mock import patch
import cv2
import numpy as np
import pytest
import to... |
1cd3bd0a1ebdf93ed4276127f4162caf9a778074b1df596d96080c683e782ce6 | Python | 16,595 | 506 | #!/usr/bin/env python
"""
Fitting for offset using correlation with a 2D Gaussian.
Hazen 04/18
"""
import ctypes
import math
import numpy
from numpy.ctypeslib import ndpointer
import scipy
import scipy.optimize
import tifffile
import storm_control.c_libraries.loadclib as loadclib
# Load C library.
c2dg = loadclib.l... |
b9e3f2e09af71377d9a376a4cbad1b6a2cc33ff95c3fa0d4851cf55c949432f8 | Python | 16,600 | 402 | """Inference function
"""
import warnings
warnings.filterwarnings("ignore")
import os, math
import subprocess
from tqdm import tqdm
from argparse import ArgumentParser
from types import SimpleNamespace
import yaml
from pathlib import Path
from multiprocessing import Process
import pandas as pd
import numpy as np
impo... |
7eec1d564cc9a27fd4362e5c2c3ee61f00dca88d88d634630f24a376177906d8 | Python | 16,602 | 372 | """
Time-Delay Embedding
====================
In this tutorial we will explore the impact of different settings for time-delay embedding (`n_embeddings`) and the number of principal component analysis (PCA) components (`n_pca_components`).
"""
#%%
# Time-delay embedding (TDE) is a process of augmenting a time series ... |
877399f5be021bf642dc94618c21f2bd71fee24144627e7ec58408e9395db096 | Python | 16,605 | 483 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import json
import pytest
from cvat_sdk.core.auth import AuthStore, ProfileEntry
from .util import TestCliBase, run_cli
@pytest.fixture
def store_path(tmp_path, monkeypatch):
from cvat_cli.__main__ import logger
original_handlers = logg... |
0267fb0715d527cb64476c5882b3618a437e85da0da1230a156783da5fc727e9 | Python | 16,607 | 288 | """
kinescope command-line interface.
Usage:
kinescope process --input <pose_dir> --output <out_dir> --dataset <name> --vid-info <csv>
kinescope predict --features <csv> --scores <csv> --output <out_dir> [--model xgboost]
kinescope convert --input <file> --format <fmt> --output <file>
"""
import argparse
import... |
15740a5c887f2daad211c7b240553aa730629180f315b21e42333c32f450aea6 | Python | 16,626 | 471 | import os
import numpy as np
from abc import ABC, abstractmethod
import hail as hl
from heig.wgs.wgs2 import RVsumstats
from heig.wgs.vsettest import VariantSetTest
from heig.wgs.utils import PermDistribution
from heig.wgs.utils import *
OFFICIAL_NAME = {
"upstream": "upstream variants",
"downstream": "downst... |
edf7410f97f0dae5aaf5c042ceb1a9784f7a2670de4a0167c9ff32321ec4a23b | Python | 16,631 | 459 | #!/usr/bin/env python3
#
# Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
"""
Dump the test CVAT database to JSON with stable ordering.
The default ``manage.py dumpdata`` output is not deterministic: record order
within a model depends on the underlying ``SELECT`` order, which can differ
between r... |
a089f8cbc813b5c040d35795284e492e7bb0aa9b8ddf7316857e68d23ab413c1 | Python | 16,635 | 443 | """Custom game rules."""
import numpy as np
from moog import game_rules
class ConvertToChoice(game_rules.AbstractRule):
def __init__(self,
agent_0_layer='agent_0'):
"""Constructor."""
self._agent_0 = agent_0_layer
def step(self, state, meta_state):
meta_state['choice_... |
a0a6bc3f7a3222bfbe1b9d7c6c44690e78e370c2911180ebeef3600978db4166 | Python | 16,640 | 457 | from argparse import Namespace
from pathlib import Path
from typing import Any
import pandas as pd
import pytest
import torch
from eir import predict, train
from eir.experiment_io.experiment_io import load_serialized_train_experiment
from eir.models.input.array.models_cnn import CNNModel
from eir.models.input.omics.o... |
7312b7e8c798eeb72df5970818e4f556ebc86626c759e1e15d4087aaa8283a3c | Python | 16,641 | 519 | import numpy as np
from itertools import chain
from util import unique, binarize_sparse, as_scalar
from bidict import Bidict
# TODO: it's strange (but convenient) that each DataItem holds target_map.
# At least for TreeDataItems, this could alternatively be accessed via the
# root. Reconsider the design.
class Data... |
cb09ce60ead46b882945ea047ee937c789145426ab3db4b78fcca9010e68acca | Python | 16,641 | 438 | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch import Tensor
from typing import Union
from torch.nn.common_types import _size_2_t
from ..util.util import gaussian_kernel
from ..ops.commons import strided_upsampling2d
__all__ = ['Filter2d', 'PascalFilter2d', 'ScharrFilt... |
cdd220862de2950a7578968add17333689ba972fa242758459e2089d11eb04d3 | Python | 16,642 | 337 | # -*- coding: utf-8 -*-
import pandas,numpy,math,multiprocessing
from functools import partial
from . import filterling
class bunchDots():
dc = 150000 #setup real dc, the side length of the square, or the diameter of the circle
use_multiply_in_find_rho = False
n_cpu = 4
window_siz... |
88f6cd17c724d8a338b15940ed5c37c4d38ad96fcf4e8f049df7524b247b26c1 | Python | 16,654 | 398 | """Check a dataset can actually be analysed, before fetching a byte of it.
Listing a remote folder returns names *and sizes* without transferring
anything, so everything worth knowing up front is cheap: which recordings the
spreadsheet names are actually present, which are missing a file the pipeline
needs, how much w... |
03ca531562e8470e55df743097dbfe68ee464170f5142b553953a37f1383d952 | Python | 16,655 | 420 | import numpy as np
import random
import os
from tensorflow.keras.models import Model
from tensorflow.keras.layers import Input, Activation, Layer
from tensorflow.keras.layers import Conv2D, MaxPooling2D, Conv3D, MaxPooling3D, Dropout
from tensorflow.keras.layers import concatenate, UpSampling2D, BatchNormalization, Re... |
291b2de9a468797fd1c7fbc89d2c043a1b80515351e1bcf60c4891592bc736b7 | Python | 16,655 | 445 | import torch
import torch.nn as nn
from mmcv.cnn import ConvModule, xavier_init
from mmcv.runner import BaseModule
from mmcv.cnn.bricks.transformer import build_positional_encoding
from depth.ops import resize
import torch.nn.functional as F
from typing import List, Dict
from depth.models.builder import NECKS
import ty... |
255058eee60339c9e5c45df39231034180c0e9b5f4b9b95dda836793d0db5822 | Python | 16,661 | 446 | import torch
import numpy as np
import scipy.stats as stats
from .utils import sample_dist
from typing import Literal
image_size = 224
visual_degrees = 7
ppd = (image_size/visual_degrees)
kernel_size = {'p': 21, 'm': 65} # 95% of Gaussian coverage
# Receptive fields of P and M ganglion cells across the ... |
2651ab0c6950185ebace2f853e547cd584620c05b457d5074f9f643cdb873158 | Python | 16,670 | 443 | # 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, ... |
a0dbf057f9c2d672e4e31bee185d1f9825c2e52a0310bbf575566d8470ab67a6 | Python | 16,671 | 452 | """Plot the encoding models' in-distribution (NSD-core) and out-of-distribution
(NSD-synthetic) encoding accuracy.
Parameters
----------
subjects : list
List of the used NSD subjects.
train_test_session_control : int
If '1', use the train and test splits consist of image conditions from
non-overlapping fMRI scan se... |
f7f543018952e479d26d530600b816a00edcb907c55c455b15c0523ef76a5e1f | Python | 16,678 | 458 | from argparse import Namespace
from pathlib import Path
from typing import Any
import pandas as pd
import pytest
import torch
from eir import predict, train
from eir.experiment_io.experiment_io import load_serialized_train_experiment
from eir.models.input.array.models_cnn import CNNModel
from eir.models.input.omics.o... |
ab85edae8f280ae09ac147d84543f12cffd71c378dc0196bc4a9f89e8f1fb69d | Python | 16,682 | 390 | #!/usr/bin/env python
"""
A utility for creating image mosaics and imaging array tomography type samples.
Hazen 10/18
"""
import os
import sys
#import re
from PyQt5 import QtCore, QtGui, QtWidgets
import storm_control.sc_library.hdebug as hdebug
import storm_control.sc_library.parameters as params
import storm_cont... |
93937ace064d6c81ed1bf963cf916d815cb9523dbc334c8ce33750cb91c700da | Python | 16,685 | 302 | import seaborn as sns
import pandas as pd
import numpy as np
from matplotlib.backends.backend_qt5agg import FigureCanvas
from matplotlib.figure import Figure
import matplotlib as mpl
mpl.rcParams['font.family'] = 'sans-serif'
mpl.rcParams['font.sans-serif'] = 'Arial'
mpl.rcParams['svg.fonttype'] = 'none'
import matplot... |
0649096ce4a396dc004df95e35ae1538c9d5d0a2ceb6ecd3e82cca388e44b7a3 | Python | 16,688 | 345 | import torch
import numpy as np
import pandas as pd
import json
import os
from transformers import pipeline
from datetime import datetime as dt
from torch.utils.data import Dataset
from tqdm import tqdm
class Twibot20(Dataset):
def __init__(self,root='./Data/',device='cpu',process=True,save=True):
self.ro... |
c6f09b43a700b2479ca9432dfff3e5f73ff0e7d4100fe2a31b9cd481fac357d6 | Python | 16,688 | 393 | # /------------------------------------------------------------------------------+
# | 22-NOV-2022 |
# | Copyright (c) Bone Imaging Laboratory |
# | All rights reserved ... |
5e5e42f5f422acbd9938624dd67b7713241f58ea6499f3fa1aad9c28727a82ea | Python | 16,696 | 547 | # Copyright 2017 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.
"""Plotting utility."""
import argparse
import iterto... |
4f487d29bb5732529638891370066d6edb89ef973d2e2a7783d0c195217230c4 | Python | 16,706 | 377 | from torch import nn
import torch
import torch.nn.functional as F
def unsorted_segment_sum(data, segment_ids, num_segments):
"""Custom PyTorch op to replicate TensorFlow's `unsorted_segment_sum`."""
result_shape = (num_segments, data.size(1))
result = data.new_full(result_shape, 0) # Init empty result te... |
a6395cbe94232d060bf52379271e9ea56cfe4907d728f579c8e892fba2241efd | Python | 16,709 | 469 | # /------------------------------------------------------------------------------+
# | 22-AUG-2022 |
# | Copyright (c) Bone Imaging Laboratory |
# | All rights reserved ... |
e76719768dd5212da3434cfb7d68579db33e445efe9eeff32e781faf07453e94 | Python | 16,709 | 473 | # Copyright (C) 2022 Intel Corporation
# Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
from enum import StrEnum
from typing import cast
from django.conf import settings
from rest_framework.exceptions import ValidationError
from cvat.apps.engine.models import Job, Project, Task
from cvat.apps.eng... |
235f8893897d5136f8a72a4bf52dcbd91472d1a08d52f9a601627e0c736058b3 | Python | 16,715 | 465 | import pytest
from eir.models.input.array import models_cnn
from eir.models.layers.cnn_layers import FirstCNNBlock
from eir.setup.input_setup_modules.common import DataDimensions
from tests.test_models.model_testing_utils import (
check_eir_model,
prepare_example_test_batch,
)
def test_make_conv_layers():
... |
e2aa1be730c21412057cd7707f6500ad4adef5a4cb863ec07e4d69c622b8980d | Python | 16,715 | 465 | import pytest
from eir.models.input.array import models_cnn
from eir.models.layers.cnn_layers import FirstCNNBlock
from eir.setup.input_setup_modules.common import DataDimensions
from tests.test_models.model_testing_utils import (
check_eir_model,
prepare_example_test_batch,
)
def test_make_conv_layers():
... |
40a8a192ece9aa806cae88df7e579701d5ef6699da47d5d94fa33ba2b0c65480 | Python | 16,718 | 483 | #!/usr/bin/env python
"""
Fitting for offset using the autofocus lock.
Hazen 09/19
"""
import ctypes
import numpy
from numpy.ctypeslib import ndpointer
import scipy
import scipy.misc
import scipy.optimize
import storm_control.c_libraries.loadclib as loadclib
# Load C library.
af = loadclib.loadCLibrary("af_lock")
... |
b1e6c92bef1e10a3850789b2dd320739c4303d4e523cfaddb619447e71c850b9 | Python | 16,722 | 452 | import numpy as np
import encore.plotters.encore_plots as encore_plots
import math
import matplotlib.pyplot as plt
import scipy.stats as stats
def plot_svd(figures, answer):
"""
Plots and saves the results of the SVD algorithm, including similarity maps, singular values,
components, and ensemble timecours... |
f9ea705159b490f795835aae711455357e7219578d86787d2051af2538c0d626 | Python | 16,725 | 482 | # Created by: Marc Canela
import pickle as pkl
from pathlib import Path
from typing import Dict, Optional
import pandas as pd
from sklearn.base import BaseEstimator
from cellrake.predicting import iterate_predicting
from cellrake.segmentation import iterate_segmentation
from cellrake.training import create_subset_df... |
112a11acf672d7703017f298fa86c1f4235bd26ca7be1950a1fc95fd14daa4e0 | Python | 16,726 | 416 | # -*- coding: utf-8 -*-
"""
Created on Thu Apr 2 16:33:34 2015
@author: ajaver
"""
import os
import numpy as np
import pandas as pd
import tables
from scipy.spatial.distance import cdist
from tierpsy.helper.misc import TimeCounter, print_flush, TABLE_FILTERS
def assignBlobTraj(trajectories_file, max_allowed_dist=... |
df7ea5f15703db8d5a2faae5408b2a352e1ee96db9327ef60211eedda181334e | Python | 16,726 | 386 | #!/usr/bin/python
# ----------------------------------------------------------------------------------------
# A basic class for the control of the new MVP valves from Hamilton: MVP4
# ----------------------------------------------------------------------------------------
# Jeff Moffitt
# 11/20/21
# jeffrey.moffitt@ch... |
685654e2f4d654ad146cfcc8d144f961446f204067b78ceb54ecb617f3a9435e | Python | 16,730 | 435 | """
tensorflow/keras utilities for the neuron project
If you use this code, please cite
Dalca AV, Guttag J, Sabuncu MR
Anatomical Priors in Convolutional Networks for Unsupervised Biomedical Segmentation,
CVPR 2018
or for the transformation/integration functions:
Unsupervised Learning for Fast Probabilistic Diffeo... |
043e8b536c66ebfc9c5d593aaf83b4a6836de52aff3c9d8fd508cda8838b0c76 | Python | 16,734 | 440 | import os
import os.path as osp
from typing import Callable, List, Optional, Union
import numpy as np
import torch
from torch_geometric.data import (
Data,
InMemoryDataset,
download_url,
extract_tar,
extract_zip,
)
class MD17(InMemoryDataset):
r"""A variety of ab-initio molecular dynamics tr... |
60058445cab51edfba02ba9a659fb7994575e4a6f0eb5ccf834ce8bd24910f94 | Python | 16,736 | 443 | # data_processing.py
import pandas as pd
import numpy as np
from rdkit import Chem
import scipy.sparse
def msp_to_dataframe_with_smiles(msp_file):
"""
Convert an MSP file with SMILES to a pandas DataFrame.
"""
data = {"smile": [], "Precursor": [], "Adduct": [], "spectra": []}
with open... |
e5ed9ace25c320ed9524c5921594bdcd2e48e3a29db1b1eae8c5d3a8c7a35272 | Python | 16,741 | 441 | from dataclasses import dataclass, field
from ._data import Segmentation, Contour, Ellipse, BreadWarning, BreadException
from ._constants import train_set_avg_cell_diameter
from typing import Any, Callable, List, Optional, Tuple, TypeVar
import scipy.spatial
import numpy as np
import warnings
__all__ = ['Features']
R... |
0635b7c8111f65183e08b41601fb790b52c6744b11a37a3a2af07eedb196782b | Python | 16,742 | 966 | # /------------------------------------------------------------------------------+
# | 22-AUG-2022 |
# | Copyright (c) Bone Imaging Laboratory |
# | All rights reserved ... |
a5394d44f3d0e94df2c0e3d2e18907cb9436961f0b3ed8fe2bd90e921b77613d | Python | 16,751 | 526 | import numpy as np
from math import sqrt
from numba import njit
from typing import Literal
from scilpy.tracking.utils import tqdm_if_verbose
def streamlines_to_segments(streamlines, streamlines_length=None, verbose=False):
"""
Separates all streamlines of a tractogram into segments that connect
each posi... |
ea8000d06bb19d3620a55ef293db8ac7258773778427009f65a801b27a88273a | Python | 16,762 | 425 | """
Copyright 1999 Illinois Institute of Technology
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publis... |
42f3ad98b29c84c88312c8adc6b949273794cd4ce002069de80eccac672b6070 | Python | 16,764 | 407 | #%%
import numpy as np
from sklearn.metrics import confusion_matrix, f1_score
import matplotlib.pyplot as plt
class Visualizer:
def __init__(self, nt, data):
"""
Parameters:
nt: an object that provides:
- nt.get_partition(): returns a 1D array of predicted class labels,
... |
3a0cf98f96dfa1b51267cc3006945a07a882508e14528631bf23757aebad4299 | Python | 16,767 | 414 | import copy
import torch
import torch.nn as nn
import torch.optim as optim
import torchvision
from torchvision import datasets, transforms, models
from torch.utils.data import DataLoader, random_split
import torch.nn.functional as F
from transformers import ViTForImageClassification, ViTFeatureExtractor
import matplotl... |
4d7d8033739090c2cec7921ef0816d14562ea00dc019e630a13dd9a96e7a37b7 | Python | 16,768 | 448 | import copy
import os.path as osp
import re
import sys
import warnings
from collections.abc import Sequence
from typing import (
Any,
Callable,
Iterable,
Iterator,
List,
Optional,
Tuple,
Union,
)
import numpy as np
import torch.utils.data
from torch import Tensor
from torch_geometric.d... |
f98bf84d70cd1b5f1a0d073a15986b8bc7c3384990cb3574f9d329642b4bfd62 | Python | 16,779 | 482 | # -*- coding: utf-8 -*-
import torch
import torch.nn as nn
import torch.nn.functional as F
from transformers import BertPreTrainedModel, BertModel
from torch.utils.data import Dataset
from seqeval.metrics.sequence_labeling import get_entities
from collections import Counter
from nerpy.ner_utils import InputExample
#... |
df58b89b8c3251793f30b19cc58a21783b8717cbe6a94b307c10a592d927bee6 | Python | 16,784 | 468 | import json
import time
from collections.abc import Iterator
from contextlib import _GeneratorContextManager
from typing import TYPE_CHECKING, Any, Literal
import numpy as np
import torch
import websocket
from PIL import Image
from sklearn.preprocessing import KBinsDiscretizer, LabelEncoder, StandardScaler
from torch.... |
eec3abfae2a4be9e56b2812d15231aa9cdd1f3dcdbeb79412a0f88f2975ccf7a | Python | 16,784 | 305 | # -*- coding: utf-8 -*-
"""
Created on Thu Jan 28 14:34:30 2021
@author: nehas
"""
import numpy as np
import sys
import pandas as pd
import glob
import pickle
import os
print (os.getcwd())
from matplotlib import pyplot
import pop_spike_utilities as psu
import GrpPlotUtil2 as grp_utl
from scipy import optimize
clas... |
fb8de5652c837f213ca0d2d4a5dc0754d49c6c585355e7f541420d18feb69604 | Python | 16,786 | 365 | import os, sys
sys.path.append('..')
import torch
import torch.nn.functional as F
import dgl
from dgl.data import DGLDataset
import numpy as np
from common import utils
from common.dataset_utils import *
from common.sampling import sample_khop, extract_cdr_seeds
from common.mapping_utils import EMBEDDING_FOLDER_MAP
OU... |
877f215b3c7ab33bdc632f2e75acacc357b6db291fd326bb3cc891e92f4c6c19 | Python | 16,787 | 374 | #!/usr/bin/env python
import json
import argparse
import os
import glob
import itertools
import pandas as pd
import sys
import time
import requests
from jinja2 import Environment, FileSystemLoader
from stringdb_query import getTaxIDfromCorrFile
# Functions
def file_len(fname):
try:
with open(fname) as f:
for i,... |
12754789cb66e5c734f71d90362dc9c7bf49364ea041923163b330f7a5e31423 | Python | 16,788 | 286 |
import sys, os, pickle, gzip
from operator import itemgetter
from Features import *
##########################
##### PARAMETERS #####
##########################
MODEL_NAME = 'model.pkl'
MODEL, SCALER = None, None
THREADS = 1
OUT = sys.stdout
SEQUENCES, SEQUENCE_NAMES, SEQUENCES_RC = [], [], []
GC = 0.5
CONTAINS... |
b64377191fa58acd17f55a29c478c0ed4231e4cac8a4a526d9e94baf5a9bb2b6 | Python | 16,794 | 346 | from typing import List, Tuple
from rdkit import Chem
from src.convert_spectrum_to_colour import *
from src.utils import DrawMol, gauss_spec_with_extinction
import matplotlib.pyplot as plt
class Molecule:
"""
This class is used for calculation and visualisation of spectral dependency on pH
We do not consi... |
186b4f99af53bb5fb7c60e251fbc6de1a39145ee1b294183d6e32c49f8c66257 | Python | 16,796 | 430 | # -*- coding: utf-8 -*-
"""
Created on Sun May 24 19:25:04 2015
@author: ajaver
"""
import numpy as np
from .cython_files.linearSkeleton_cython import chainCodeLength2Index, circOpposingNearestPoints, \
getHeadTailRegion, getInterBendSeeds, skeletonize, cleanSkeleton
#% Find points_ind between startI and endI, i... |
56d14edeaff02425e72d3e9538ae40a31f726ff96cdc284c2f86f2ad415852af | Python | 16,799 | 511 | import json
from pydantic import BaseModel
from langgraph.graph import StateGraph, END
from langchain_core.messages import ToolMessage
from langchain_openai import ChatOpenAI
from langgraph.checkpoint.memory import MemorySaver
from chemgraph.tools.ase_tools import (
run_ase,
save_atomsdata_to_file,
file_to_... |
f5f6f16304f978b770be6ab69f4906897d13930c422642ddc73946997acb0e2d | Python | 16,802 | 464 | import h5py
import nibabel as nib
import numpy as np
import pandas as pd
# import numba
from scipy.ndimage import label
from concurrent.futures import ThreadPoolExecutor
import heig.input.dataset as ds
from heig.wgs.utils import list_datasets
from heig.utils import find_loc
"""
Threshold-free cluster enhancement (TFC... |
7f5190fa1b0e76a545bb06a62c35a125292fc823dd9062b0894e3e2ffb7494b1 | Python | 16,803 | 383 | import numpy as np
import pandas as pd
import distinctipy
import matplotlib.pyplot as plt
from skspatial.objects import Line, Points # scikit-spatial package: https://scikit-spatial.readthedocs.io/en/stable/
from napari_dmc_brainmap.utils import get_animal_id, get_info, get_bregma, coord_mm_transform
def get_primary_a... |
fe1a9fa326305b3964e3193a53a74e7f72880b5aca4612fe6fdfb152e4957660 | Python | 16,809 | 515 | import argparse
import datetime
import json
from typing import Any
import numpy as np
import scipy.stats as stats
class TermColors:
GREEN = "\033[92m"
RED = "\033[91m"
YELLOW = "\033[93m"
BLUE = "\033[94m"
BOLD = "\033[1m"
UNDERLINE = "\033[4m"
END = "\033[0m"
def load_report(file_path:... |
0aa5dedfc6a4fcb547c6111a8f77a1cb80ca52b18904bb23a6ab9f538c4c62cd | Python | 16,812 | 530 | """
LEMON: EEG Batch Processing
===========================
This tutorial shows how to process a large EEG dataset in batch using
osl-dynamics' parallel processing utilities. We use the
`LEMON dataset <https://ftp.gwdg.de/pub/misc/MPI-Leipzig_Mind-Brain-Body-LEMON/>`_
as an example.
The pipeline mirrors the single-se... |
2bee2d1de4b52f430a644c9173315f960db116924bda3a039189809ffd0e166f | Python | 16,812 | 404 | #!/usr/bin/env python
"""
Spot counter. This performs real time analysis of the frames from
camera. It uses a fairly simple object finder. It's purpose is to
provide the user with a rough idea of the quality of the data
that they are taking.
Hazen 05/17
"""
import sys
import time
from PyQt5 import QtCor... |
9a54b60aac9360c48e3b131413e0abdb74cfd8125c9927220fb7b6310e3a97ff | Python | 16,814 | 331 | """Represents the configuration for Sphinx, which is executed at build time and can be used to configure Sphinx's input and output behavior."""
# pylint: disable=invalid-name
import inspect
import os
import sys
import typing
from collections.abc import Iterator, Sequence
from datetime import datetime
from subprocess ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.