sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
eeac94b4a854f087453e5c85f29ad3bb4f09c78d4139cb897757c6b8d28a5d1a | Python | 9,219 | 189 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# ht... |
a585b643c67990d20608a3e723907425708825c79852678512dd9445bf16f476 | Python | 9,222 | 133 | import numpy as np
from rdkit.Chem import rdFingerprintGenerator
def create_sort_and_slice_ecfp_featuriser(mols_train,
max_radius = 2,
pharm_atom_invs = False,
bond_invs = True,
... |
d1cd9ce01ac8aa7e68e3ca2643ff1a1f95942ddd951790574d5866a3abe5ec83 | Python | 9,222 | 257 | from __future__ import annotations
import os
from functools import cached_property
from pprint import pformat
from typing import Optional
import pandas as pd
from sklearn.model_selection import StratifiedKFold
from cuppa.classifier.cuppa_classifier import CuppaClassifier
from cuppa.classifier.cuppa_prediction import... |
e5f8e1ad34d4cb3cd10771c387e6ba6ff4d34390335202b18f3ccc99e8e17386 | Python | 9,222 | 245 | # Copyright (c) 2023-2024 Blue Brain Project/EPFL
# 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 ... |
fa717141c433af90616f4de6154fb3b7088eb1577f799762c9bbe04b94813b19 | Python | 9,225 | 265 | import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
import scipy
from sklearn.decomposition import PCA
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA
from sklearn.manifold import TSNE, spectral_embedding
from sklearn.cluster import KMeans, SpectralClustering, k_means
fr... |
3f862556d14399de572423d6cce9b8f279debe28f7fa8cf80d62a47232024ba8 | Python | 9,230 | 257 | from __future__ import annotations
import argparse
from pathlib import Path
import pandas as pd
import json
from typing import NamedTuple, Any
import numpy as np
import matplotlib.pyplot as plt
import mech_parser_args
from mechanotransduction_ode import mechanotransduction_ode_calc
var_names_all = ["Cofilin_P", "Fak"... |
6e3f2f93a30666d1601cd67161fc9dd937e76d2379a26c4b763818d132215f43 | Python | 9,232 | 273 | # Node group ".MN_select_res_name_peptide" (GeometryNodeTree), dumped by nodebpy.assets.dump_library.
# Rebuild the library with nodebpy.assets.build_library (nodebpy build).
# Shared by several assets, which import it; not an asset itself.
# _build_group() is the source of truth: the docstring, __init__ and accessors ... |
d2dfa5e774869ccc9802db96009e7b556f960601b5924aa8e5b14d9d8ccfd642 | Python | 9,237 | 250 | """
Script for extracting an analyzing the filaments attached to a membrane from several input datasets
DEPRECATED: USE mb_graph_batch.py instead
Input: - Density map tomogram
- Segmentation tomogram
Output: - Connectors clusters
"""
__author__ = 'Antonio Martinez-Sanchez'
# #########... |
bd09b58d209df3a1427d3f154f40d372d49f571078e6a9f4ccb9cacc82217976 | Python | 9,242 | 241 | """Build the modified 3-D annotation and export the session artifacts."""
from __future__ import annotations
import logging
from datetime import datetime
from pathlib import Path
import numpy as np
from .contour_edit import apply_slice_edits
from .quantify import (
attach_region_names,
quanti... |
02c63ad8a0cee63580d5eb520e42a5d7a2fccf17d4e4acbc1dd5b83a4d00a40b | Python | 9,244 | 244 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... |
0d6e5a465dcc70c3acf82524c37c5299f7c0f75e0da57f59538fdc23c9334d75 | Python | 9,244 | 196 | # Copyright 2006, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the f... |
65cf6f8860b71faa4c29687c3d447709541f7c6656152182369bba393a4e90e6 | Python | 9,244 | 173 | import builtins
import getpass
from unittest.mock import patch, MagicMock
import keyring
import pytest
from keyring.errors import KeyringLocked
import NDATools.Configuration
from NDATools.Configuration import ClientConfiguration
from tests.conftest import MockLogger
username = 'test_username'
password = 'test_passwo... |
3b46bcb753471cc305a752e6ad24ac41c45e980f2cf40656cd334db261b30f39 | Python | 9,245 | 221 | # Copyright (C) 2003 CAMP
# Please see the accompanying LICENSE file for further information.
r"""
Real-valued spherical harmonics
=== === === =======
L l m
=== === === =======
0 0 0 1
1 1 -1 y
2 1 0 z
3 1 1 x
4 2 -2 xy
5 2 -1 yz
6 2 0 3z2-r2
7 2 1 zx
8 2... |
22d89369d63c39db12c6ce84ddbc1c81924a2a8d726b88519e46d1131bcb529b | Python | 9,248 | 277 | """Provide data structures for multivariate analysis.
Code is adapted from Patricia Wollstadt's IDTxL (https://github.com/pwollstadt/IDTxl)
"""
import numpy as np
import pandas as pd
from pyspi import utils
from scipy.stats import zscore
from scipy.signal import detrend
import os
VERBOSE = False
class Data:
"""... |
e2de3782fde4a6b91730cee81aa27d23c8ee3e8525b32f281556af0bde47be3c | Python | 9,250 | 220 | """
@Mariellapanag
Created on May 2023
@author: mariella and chris, CNNP Lab
Calculates the AUC of the cycles power on SOZ against other regions.
output: saves these to the AUCs folder, and produces figures 1 (a,d) and 2 (a,c)
"""
# external modules
import numpy as np
import os
import matplotlib
import matplotlib.p... |
77ba5cfee229627ccb6d114fc6306e7196bcc96b83c9a4cd74230498dcf1a71b | Python | 9,252 | 232 | """
Script for GraphMCF simplifaction
Input: - File with a GraphMCF (.pkl)
- Simplification parameters
Output: - Simplified GraphMCF
"""
__author__ = 'Antonio Martinez-Sanchez'
# ################ Package import
import sys
import time
import getopt
from pyseg.globals import *
from pyseg.... |
14de853ed5bb630a55bcc5fa572ff49b6aa19b057bf2afd6659292a399f1ca8c | Python | 9,253 | 212 | # coding=utf-8
# Copyright 2019-present, the HuggingFace Inc. team, The Google AI Language Team and Facebook, Inc.
#
# 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.or... |
a11d1437e0893cf17ff4fe2cd4caa1bc8cda9210899cfe5c67e37558aea19caa | Python | 9,253 | 309 | """Utility functions for file and path handling."""
from __future__ import annotations
import contextlib
import logging
import os
import socket
from copy import deepcopy
from datetime import datetime, timezone
from pathlib import Path
from random import randint
from shutil import copy
from typing import TYPE_CHECKING... |
c96205b9982ef5fde754f0ac02d376ba8621074ba3af7d772f7f0cd36b9bd53e | Python | 9,259 | 205 | from typing import Tuple
import torch
import torch.nn as nn
class BCEncoder(nn.Module):
r'''
TorchEEG provides an EEG feature encoder based on CNN architecture and CVAE for generating EEG grid representations of different frequency bands based on a given class label. In particular, the expected labels are ad... |
2cc46f89f9c9f67d54c36354b905bb67c92bc3fa53e979d7eec34821a330abcb | Python | 9,260 | 241 | import matplotlib
matplotlib.rcParams['figure.facecolor'] = '1.'
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
import nibabel as nib
import pandas as pd
import re
import os
import ants
import argparse
import csv
import statistics
from scipy.ndimage import distance_transform_edt
from scipy.nd... |
647ddda9bb1286b0d59f6fa2815a8e20c8779f3f71bb2abb4c6a01448e744e87 | Python | 9,263 | 226 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... |
a2322174d814e29b955a16584fe1d14a2f45e310e71c159c69ecbb026f1be369 | Python | 9,264 | 272 | import torch
import torch.nn as nn
import torch.nn.functional as F
from ..initializer import create_initializer
class BasicBlock(nn.Module):
expansion = 1
def __init__(self,
in_channels,
out_channels,
stride,
remove_first_relu,
... |
93471596814fdb679028596a6bc7020f90e1a3f46d2e40777090d3794cb3a178 | Python | 9,266 | 225 | '''
This model fits the dipole and quadrupole of the inputs to the atomic charges
and predicts dipoles and quadrupoles.
Dipoles and quadrupoles are expressed as
μ(r) = ∑ qi · ri
and
Q'αβ (r) = ∑ qi · (3rαi · rβi − δαβ · |ri|^2),
where q is the atomic charge, r are atomic coordinates and α, β ∈ {x, y, z}.
The defin... |
4e60240ccae6b922dfb52fb9733fd55e0607113e8bfd5b101e3064601783af26 | Python | 9,268 | 255 | #
# MIT License
#
# Copyright (c) 2022 GT4SD team
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge,... |
070aa1b1db92a72b7bf67b98900d83643e2d809dbc7aca9fe45825b1e9fc148f | Python | 9,270 | 303 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... |
14357e5a63cbaf934b9746d9ceaa4f3eed1f23e463153a73cede747b376ed8f2 | Python | 9,272 | 311 | ##
# \file registration_method.py
# \brief Abstract class to define a registration method
#
# \author Michael Ebner (michael.ebner.14@ucl.ac.uk)
# \date Aug 2017
#
# Import libraries
import numpy as np
import SimpleITK as sitk
from abc import ABCMeta, abstractmethod
import pysitk.python_helper as ph
i... |
6d69bdcfaa9b304e68ddb97039410cd3ba18b8257dc2132a81d9e22057fe7086 | Python | 9,273 | 182 | # -*- coding: utf-8 -*-
import torch
import torch.nn as nn
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
from supar.config import Config
from supar.modules import (CharLSTM, ELMoEmbedding, IndependentDropout,
SharedDropout, TransformerEmbedding,
... |
82c575b6a6d1642b6aaaf6c0b58462a3783c5deb2bd9a8be959c0e8ada567b9c | Python | 9,276 | 289 | import string
from itertools import zip_longest
from codex.data.neurotransmitters import NEURO_TRANSMITTER_NAMES
from codex.utils.formatting import make_web_safe, can_be_flywire_root_id
# removes left/right hemisphere annotations (this might be inaccurate due to left/right inversion problem from May 2023)
def remove... |
b78730bb05d6dc378819df6d7f82d6a904e7b0db117060e2219c52fc8c6dd19b | Python | 9,279 | 190 | import random
import math
import time
from math import sqrt
class Neuron():
def __init__(self, inputs):
'''The neuron has a list of weights, each connecting to a neuron in the previous layer. When the neuron is activated, it multiplied the output of all neurons in the previous layer by the connecting weigh... |
be61b4782f2cce229d754d1facffca54dd68ba01182f71a7db5bad8b894c7fe3 | Python | 9,281 | 158 | #!/usr/bin/env python3
import argparse
import os
import subprocess
from glob import glob
import pandas as pd
__version__ = "1.0.0"
def run(command, env={}):
merged_env = os.environ
merged_env.update(env)
process = subprocess.Popen(command, stdout=subprocess.PIPE,
stderr=sub... |
b17068a8ba9e332eb1d38e2a2cd2c91171e382f042c74b5318738205583580f5 | Python | 9,284 | 262 | # Computing the Frechet distance between two polygonal curves.
# International Journal of Computational Geometry & Applications.
# Vol 5, Nos 1&2 (1995) 75-91
from .basic_euclidean import eucl_dist, point_to_seg, circle_line_intersection, eucl_dist_traj
def free_line(p, eps, s, dps1, dps2, ds):
"""
Usage
... |
3297bf45ff2b7d498074fb0a6d26189bb37754eb678e55ea244f3bd8593bf9eb | Python | 9,286 | 310 | from collections import defaultdict, namedtuple
from codex.data.brain_regions import NEUROPIL_DESCRIPTIONS
from codex.data.neurotransmitters import NEURO_TRANSMITTER_NAMES
from codex.utils.formatting import nanos_to_formatted_micros, display
def group_counts(count_pairs):
key = f"{len(count_pairs)} others"
v... |
994c46d6d752fff7411ca54a057950f79e26c3dcd37304cfb10e20515aa06031 | Python | 9,288 | 206 | from typing import Any, List, Tuple, Union
import numpy as np
import pytorch_lightning as pl
import torch
from torch import Tensor, nn
from torch.nn import functional as F
from torch.utils.data import DataLoader
from ..classifier import ClassifierTrainer
class LDAMLoss(nn.Module):
def __init__(self,
... |
79f5b7efcf767db0fa0d99f496205233baa9d40832218cdb19dbf8d80978e28c | Python | 9,289 | 255 | # -*- coding: utf-8 -*-
"""
Created on Thu Dec 8 19:49:49 2022
@author: Dustin Garner
"""
import os
import time
import math
import collections
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from fafbseg import flywire
import flycode.utils as utils
import flycode.readfil... |
9a44da19ed3d544686ff008a57ab924054484be55fa06bb23c25b62ecd77c81f | Python | 9,290 | 256 | #!/usr/bin/env python
#VCF preprocessing utils
import itertools
import pandas as pd
import io
import re
from collections import Counter
import math
def ExtractSamples(vcf,return_dict=False):
'''
Extraction of sample names from VCF
'''
with open(vcf, "r") as lociList:
for line in (line for line in lociList if... |
61248c8ff2de6432f382f8db40a14609ada41e46649e215f677bbfcee1f94858 | Python | 9,291 | 278 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... |
40060377eb36ac4a717e54d2058b6a2258b33cdadfbec161c0129a0b87a541d6 | Python | 9,293 | 247 | import pandas as pd
import numpy as np
import glob
import os
from logging import raiseExceptions
import nelpy as nel
from cmath import nan
def load_data(data_dir, pattern = 'ol_scoring.csv',var_names = ['file','frame','action']):
"""
Load behavior_coding.py output csv from a directory
"""
# find output... |
752a7b14a52c7d7f06e54846e8ba90fa9ee7881103c60c59f25027822ee05ebe | Python | 9,293 | 302 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... |
d71fb754a57e9e263d1e8407cea1409649ec484da76f32402850b8fef2038c31 | Python | 9,295 | 254 | import os
import warnings
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from anndata import AnnData
from matplotlib.lines import Line2D
from matplotlib.pyplot import Figure
from numpy import ndarray
from pydeseq2.dds import DeseqDataSet
from pydeseq2.default_inference import DefaultInference
f... |
0671e70ee33776e07bcddcc3b4f49f4535e882ee3cf73c2588d4ad006045ce15 | Python | 9,296 | 205 | """
Script to run pan-cancer classification experiments for a given (fixed) lasso
penalty, using L1 penalty only.
"""
import sys
import argparse
import itertools as it
from pathlib import Path
import numpy as np
import pandas as pd
from tqdm import tqdm
import pancancer_evaluation.config as cfg
from pancancer_evaluat... |
6fbe7b6b7f635c049acd8127f819c4839d8359f60dd40911452f867b369d04a2 | Python | 9,301 | 286 | import math
import numpy as np
from typing import Optional
import torch
import torch.nn.functional as F
__all__ = [
"focal_loss_with_logits",
"softmax_focal_loss_with_logits",
"soft_jaccard_score",
"soft_dice_score",
"wing_loss",
]
def to_tensor(x, dtype=None) -> torch.Tensor:
if isinstance... |
e0a4c47f0b93ebc48e4aa0360d36bfcc18f8ae4412d48be00bbf869df09b3f9b | Python | 9,302 | 238 | import time
import numpy as np
from .utils.mpi import distrib_vec, is_master, MPI, comm
from .utils.misc import mytqdm
from .io.aodata import calc_FT_kg_orb_spcs
from .matao.matao import MatAO
def Hpw_to_Hao_wfn(structure, wfndata, aodata, pairs, wfn_proj_atoms, nbndmin, nbndmax,
band_shift=0):
... |
f0a7d8e7ec2fd107693299874675d5b67e2cc40f1e72881f0d944c2af0344219 | Python | 9,302 | 279 | """
Script for analyzing synapse gap distance
Input: - A STAR file with the synapse segmentations
Output: - Synapse gap length distribution
"""
import vtk
import numpy as np
import scipy as sp
__author__ = 'Antonio Martinez-Sanchez'
###### Global variables
MB_PST, MB_PRE = 1, 2
START_IDX, END_STR... |
c93d35391c6c6970af79e4049f8b36a561c82202cd195f491780e26fed67852f | Python | 9,305 | 248 | """
Generates ListTomoParticle objects from a previous one file (light particles version) and AP clustering
Input: - ListTomoParticle STAR file
- Particle vtkPolyData
- AP clustering settings
Output: - A ListTomoPaticles where previous particles have been substituted by culsters ... |
e74bd9b48b50524821fcf793eb5a029e3d595ad3ef9eb3ff846600eda904a05e | Python | 9,306 | 254 | #! /usr/bin/env python2.6
# -*- coding: utf-8 -*-
import sys
TIMEOUT = 1800
EPSILON = 0.0001 # Don't care about this little time.
class Results(object):
def __init__(self, file):
self.configs, self.problems, self.data = self._parse_entries(file)
self._add_missing_entries()
assert len(se... |
3144bbe24af75e483ad2504592f94f09b725a2c04303d48bc94d8fe11ee2235d | Python | 9,309 | 209 | import os
import re
from urllib.parse import quote, unquote
from typing import Iterator, Dict, List, Tuple, Union
import pandas as pd
from sklearn import model_selection
from torcheeg.datasets.module.base_dataset import BaseDataset
from .base_model_selection import BaseModelSelection
from .utils import create_subset... |
a04be9ab60d2501793092651374e1a73f7c21109fc88e837ce1f5e9a07911684 | Python | 9,313 | 207 | """Turning two clicks on the preview into a plane the RUN can use.
The clicks land on the atlas pane, which holds a PIR-reoriented, in-plane
STRIDED copy of the template (``arr[:, ::s, ::s]``). The run holds the
full-resolution volume in the file's own frame. A midline recorded in the
first frame means nothing in... |
cd5d2fd3a77ab2fc16a2f9e4e7aa9c05a5e7301b0f6af2998719a2c0a6d63754 | Python | 9,314 | 264 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 10 11:05:50 2024
@author: Dustin Garner
"""
import os
import collections
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import flycode.mapping as mapping
import flycode.reduction as reduction
import fl... |
731250dc435a3ba5546c3c8075e13deac15cc3412fbb3bb792d59e34f51fbb39 | Python | 9,315 | 267 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... |
139d122ddb72125aaab9d7da8d0b37d1939aa6ae58cb0e7c49149d46faefaa74 | Python | 9,317 | 247 | #!/usr/bin/python3
import os
import glob
import shutil
import numpy as np
from osgeo import gdal
from cnn_exceptions import DatasetError
def generate_dataset_structure(data_dir, tensor_shape=(256, 256),
val_set_pct=0.2, filter_by_class=None,
augment=Tr... |
ddd5faac2dd05d4735868d471cdc55ed8d9c80595ea442100e60b21ea18b7930 | Python | 9,318 | 264 | """Detector core: sigma, threshold, run-length grouping, end-to-end."""
from __future__ import annotations
import numpy as np
import pytest
from msfeature.detect import (
compute_sigma,
detect_microsaccades,
elliptic_threshold_mask,
extract_runs,
)
from tests.conftest import InjectedSaccade, build_tr... |
90cf41206c08c0ee694a0e5aac42455a6468bc158b03fe0889021944d8887837 | Python | 9,320 | 233 | # Node-group asset "Animate Frames" (GeometryNodeTree), dumped by nodebpy.assets.dump_library.
# Rebuild the library with nodebpy.assets.build_library (nodebpy build).
# _build_group() is the source of truth: the docstring, __init__ and accessors are regenerated from it on the next dump.
from typing import TYPE_CHECKIN... |
65eb1f80308a2c5eceea770fb8ba69a4739ccdf62c37eef8c127b1e79ee8150c | Python | 9,321 | 238 | """
Pre-process two inputs of segmented membranes to generate pairs.
Each pair of membranes consisted in two membranes, labeled as 1 and 2, lummen or gap space,
label 3, and citoplasmic sides, one on each membrane labeled as 4 and 5 respectively
Input: - Reference tomogram
- Segmentation... |
926d6c7848ae772ab55b4427d7558358ba1b68bb256d55e98d66d3ea99c918bf | Python | 9,326 | 220 | import unittest
import numpy as np
from torcheeg.transforms import ToGrid, ToInterpolatedGrid, To2d, MeanStdNormalize, MinMaxNormalize, BandSignal, BandDifferentialEntropy, BandPowerSpectralDensity, BandMeanAbsoluteDeviation, BandKurtosis, BandSkewness, Concatenate, MapChunk, PickElectrode, CWTSpectrum, ARRCoefficient... |
9388ea765d8cf22fcbbe84295615464f824866702fb11634eed8aa5304b025f4 | Python | 9,331 | 201 | import matplotlib.pyplot as plt
import numpy as np
import os
import pandas as pd
from scipy import stats
from tabulate import tabulate
from constants import DATA_DIR, SCORE_COLUMNS, CI_CONFIDENCE
from src.analyze.utils import init_mpl
from src.preprocessing2.process_ratings import merge_rating_files
from src.utils imp... |
b8987cef95b11fc282226baa447332ce0c8e7f79bef02cdce4ccec6882379d1c | Python | 9,331 | 240 | """
Unsupervised and deterministic classification test for PCA-KMEAS algorithm
Input: - The STAR file with the particles to classify
- Ground truth mask
- Classification parameters
Output: - A set of STAR files with the new classes
- 2D rotational averaged around memb... |
08ef0ab0a7b774048ad02aa04ea611361f044956dd191f288638357bf843107b | Python | 9,332 | 267 | # --------------------------------------------------------
# Based on BEiT, timm, DINO and DeiT code bases
# https://github.com/microsoft/unilm/tree/master/beit
# https://github.com/rwightman/pytorch-image-models/tree/master/timm
# https://github.com/facebookresearch/deit
# https://github.com/facebookresearch/dino
# --... |
2f360fc41dd5ac25ce57b72f1ce2023bfbb9de50ea76f4e71e6ba668443c4756 | Python | 9,333 | 225 | """
Script to train pan-cancer mutation classification models on TCGA data and
evaluate them on CCLE, or train on CCLE and evaluate on TCGA.
"""
import sys
import argparse
import itertools as it
from pathlib import Path
import numpy as np
import pandas as pd
from tqdm import tqdm
import pancancer_evaluation.config as... |
4ce0cfda74625574ef0123d31615bd9475b891ba3fd258b54a777e5ab20f7649 | Python | 9,339 | 295 | """
Visualization of components and groups hyper-parameter space.
"""
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colors as colors
from scipy.stats import binom
from help_funcs import load_exp_variables
# ----- #
# Data loading.
data = "zhou2016" # "zhou2016", "2014004", "2014001", "muni... |
3a10cba046292fad34c950b1d76642bae628e80a6b6b225dbf4ada0b7def5446 | Python | 9,340 | 221 | """Tests for fixed-mask support in antsRegistration."""
import os
import tempfile
import numpy as np
import pytest
def _write_annotation(path, shape=(8, 8, 8)):
"""Write a small integer-valued annotation NIfTI for testing."""
import nibabel as nib
data = np.zeros(shape, dtype=np.int32)
... |
f6adf6e498ea70cc9031be37e3f627123ec5533e9e74e2920a695a14a05bf8da | Python | 9,340 | 208 | import os
import re
from urllib.parse import quote, unquote
from typing import Iterator, Dict, List, Tuple, Union
import pandas as pd
from sklearn import model_selection
from torcheeg.datasets.module.base_dataset import BaseDataset
from .base_model_selection import BaseModelSelection
from .utils import create_subset,... |
0a7d518ae3a7b73f4bf44caac58e8f9a5af5e5f917126d82751085bb9aeb303c | Python | 9,341 | 295 | import numpy as np
import torch
def supergauss2d(N,sc,p,t):
x = np.linspace(-N/2, N/2-1, N)
y = np.linspace(-N/2, N/2-1, N)
xv, yv = np.meshgrid(x, y)
return (1-t)*np.exp(-np.power(xv/(N*sc),p)) * np.exp(-np.power(yv/(N*sc),p))+t
def super_gaussian(sg_params,N,isfloat=True):
... |
7e908b8392ce59152466ec5cfa4458fa6c0ba4d18ab9ee02acece398a5d54bad | Python | 9,342 | 273 | from __future__ import annotations
import os
from logging import WARNING, getLogger
from pathlib import Path
from shutil import copytree, move
from types import SimpleNamespace
import pytest
from ase.io import read
from monty.json import MontyDecoder, jsanitize
from quacc.calculators.vasp import Vasp
from quacc.sche... |
7cd5d885cd5e1f40f3c2d68049e1c57cf3ef15c5f5107703c266b6147ad4859b | Python | 9,346 | 238 | # -*- coding: utf-8 -*-
"""unit tests for bpnn implementation"""
import pytest
import numpy as np
import tensorflow as tf
def _manual_sfs():
lambd = 1.0
zeta = 1.0
eta = 0.01
Rc = 12.0
Rs = 0.5
a = np.array([0., 0., 0.])
b = np.array([1., 0., 0.])
c = np.array([1., 1., 0.])
ab = b-... |
4a1132bcf5e5b502bbe02b654447065491d9f1bb68a490773ee2a864ad55dd3b | Python | 9,347 | 226 | #!/bin/usr/python3
# Use example: python run_highresnet.py ../data/train1/BIDS_data_brain output_highresnet_train1
## Import libraries
import time
import datetime
from pathlib import Path
import os
from glob import glob
import argparse
import nibabel as nib
import numpy as np
import pandas as pd
from utils.helper... |
0f010d11493ad7456a5027832e1861a59a7cf4bd81ee92a9e77c7f6253f03e88 | Python | 9,348 | 255 | """
Script for getting the graph MCF from a tomogram
Input: - Original tomogram (density map)
- Mask (optional)
Output: - GraphMCF object in a pkl file
- vtkPolyData with the membrane and the attached structures
"""
__author__ = 'Antonio Martinez-Sanchez'
# ################ P... |
f7eb32f4a9f1667a0292279691b9c818e5e21a1ba5e56dbe2b5b3dca2e75fe19 | Python | 9,348 | 301 | """Fingerprint array comparison metrics.
Each is fully compatible with both dense and sparse inputs.
Author: Seth Axen
E-mail: seth.axen@gmail.com
"""
from __future__ import division
import numpy as np
import scipy
from scipy.sparse import csr_matrix, issparse, vstack
import scipy.sparse.linalg
import scipy.spatial
... |
b70c5a912cda5ff20ad49d7595cb3db423bf7e81d42a3b65bed1cc09cf4e3daa | Python | 9,349 | 300 | # set QT_API environment variable
import os
import sys
import time
os.environ["QT_API"] = "pyqt5"
import qtpy
# qt libraries
from qtpy.QtCore import *
from qtpy.QtWidgets import *
from qtpy.QtGui import *
import time
import numpy as np
from control._def import *
class NavigationController_PriorStage(QObject):
... |
afc246f3052f4a5546eee2397ffcf38b61b16421ca07cb0accd60af866597ad9 | Python | 9,350 | 284 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... |
1ef9fd3d521ad3e0b020f8171bc1d63f71929717d2d7b8a86f16d4024ac217c7 | Python | 9,353 | 168 | import sys; sys.path.append(r"path to source codes")
from ImageUtitlities import *
from glob import glob
import os
import SimpleITK as sitk
from termcolor import cprint
from tqdm import tqdm
import time
import timeit
import numpy as np
import torch
def predict_multi(list_images : list,
target = "inplace... |
4fddffb02ed7b38df4e4b42e96d12e32832d70d67659362cc74d819dbdd2c382 | Python | 9,355 | 250 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... |
689b0f923b18e22f1ae8fb78a1753e9639e088158d304d867692704810ed664e | Python | 9,355 | 228 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# ht... |
967080ac8836e62bb68c529fdf29d5f48158bf5f68e2e9a6136fe5e4b0f5bde7 | Python | 9,355 | 243 | # regtools/updater/gui.py
"""Version & Update dialog - a sectioned, non-blocking shell over updater.core.
Git ops run off the main thread via regtools.gui.worker.run_async so the window
never freezes. On open the dialog shows local version info instantly, then
auto-checks (fetch + behind-count) in the background.... |
c63fdea6e337ce34ef5672c3253b9e50ef397e604ac745f50678311fa6c86c81 | Python | 9,359 | 188 | import pandas as pd
import numpy as np
import warnings
warnings.filterwarnings(action='ignore')
import matplotlib.pyplot as plt
import json
from sklearn.neural_network import MLPClassifier
from sklearn.pipeline import Pipeline
from sklearn.metrics import classification_report ,roc_auc_score, f1_score, average_precision... |
02fbf8f554fe8551bc4e69a1d26b3ba06321efb2a01dd78c50ebc9f23e2b59ac | Python | 9,365 | 245 | import json
import multiprocessing
import os
import tempfile
import unittest
from pathlib import Path
import numpy as np
from filelock import FileLock
from torcheeg import transforms
from torcheeg.datasets import BaseDataset
class _CachedDataset(BaseDataset):
def set_records(self, root_path, **kwargs):
... |
3a64a6c6c28b56c53b1b3b83f6e94958c890432c35e4a361cda275d98b8feccb | Python | 9,369 | 198 | import sys
import unittest
from unittest.mock import patch
import pandas as pd
import os
import sys
sys.path.append(os.path.dirname(os.path.realpath(__file__)) + "/../../src")
sys.path.append(os.path.dirname(os.path.realpath(__file__)) + "/../../scripts")
from train import args, train
class TestTrain(unittest.TestCase... |
84b61b3bc5c0d81345b55d62b3c7d3b2bb12858e59cf718353d549ed8aabf448 | Python | 9,369 | 263 | ''' Script to perform decoding of MEG data. Options include decoding in source and sensor space
with optional masking of ROIs as well as filtering and smoothing parameters.'''
# Append to path
project = 'MINDLAB2020_MEG-AuditoryPatternRecognition'
project_dir = '/projects/' + project
scripts_dir = project_dir + '/scri... |
0db6f483f0e78ea9d4be4dc8729fbc255041b31aeca372786c503b155b320b04 | Python | 9,371 | 171 | #!/home/zhangjx/anaconda3/envs/dynamicbind/bin/python
import numpy as np
import pandas as pd
import os
import sys
import subprocess
from datetime import datetime
import logging
import rdkit.Chem as Chem
def do(cmd, get=False, show=True):
if get:
out = subprocess.Popen(cmd,stdout=subprocess.PIPE,shell=True... |
23ca099a01ce063bb4e1126be2ac39b96c0a7fe64b8b0514cab40fb4587c66c1 | Python | 9,371 | 224 | # -*- coding: utf-8 -*-
"""
Created on Thu Dec 10 11:52:54 2020
@author: aabdulaal
................................................................................................................................
"""
import numpy as np
import tensorflow as tf
from tensorflow.python.keras.constraints import NonNeg
from ... |
de92b54ba43572545722c4dbc17813355d3a77bf330e69e5d73c5848dade0aa4 | Python | 9,371 | 223 | # -*- coding: utf-8 -*-
"""Basic functions for PiNN models"""
import threading
import tensorflow as tf
from pinn.utils import pi_named
_infer_dtype = threading.local()
def tf_dtype_from_name(name='float32'):
"""Map TF dtype name ``float32`` / ``float64`` to a ``tf.DType``.
``None`` defaults to ``tf.float32`... |
19079c53a1c5c80ac13248e78da8c46e72e58fec151281d0f370e1bd0bfbeed9 | Python | 9,372 | 255 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jul 26 13:37:15 2021
@author: leupinv
"""
import mne
import evoked.evoked_constants as ev_cs
import os
import numpy as np
import evoked.evoked_constants as cs
class EpochGroup():
def __init__(self):
self.vep_group = []
self.hep_grou... |
4b18a57a464530eb8b27f96ce0a1d85489f0d6423fc32b0d2c44027071d596aa | Python | 9,372 | 208 | """
DeepLabCut2.0 Toolbox (deeplabcut.org)
copyright A. & M. Mathis Labs
https://github.com/AlexEMG/DeepLabCut
Please see AUTHORS for contributors.
https://github.com/AlexEMG/DeepLabCut/blob/master/AUTHORS
Licensed under GNU Lesser General Public License v3.0
"""
import os, pickle, yaml
import pandas as pd
from pathl... |
91af90c857dfdf1f823a1c64df7cda03ce1fff022379a7d539a44211f86f8c05 | Python | 9,375 | 262 | # coding=utf-8
# Evaluation code courtesy of Juan Nunez-Iglesias, taken from
# https://github.com/janelia-flyem/gala/blob/master/gala/evaluate.py
import numpy as np
import scipy.sparse as sparse
def voi(reconstruction, groundtruth, ignore_reconstruction=[0], ignore_groundtruth=[0]):
"""Return the conditional ent... |
d707ad2a3c9be71e2d05f78dd8cff03b74d8f1f454f0ed18949b131663c44876 | Python | 9,375 | 197 | # VERIFIED 7/2/2024 TO FUNCTION AS INTENDED ON DATA PRESENT IN DIRECTORY
# Revised 11/24/2024
# Necessary Libraries
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy.spatial.distance import cdist, pdist, squareform
import math
import itertools
import warnings
from scipy.stats import tt... |
ffb47b13fac1762d1790fe7421a9928ec5efd3f07fac8e1d1dd3839bdc9a36d0 | Python | 9,375 | 297 | import sys
import torch
import numpy as np
import torch.nn.functional as F
from typing import Literal, Optional, Dict, List, Callable, Tuple, Union
def setup_seed(seed):
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
np.random.seed(seed)
torch.backends.cudnn.deterministic = True
def expand... |
d86555277b29ccec029a72702c6f7b03617163f66da3f5bac421f49cf71f5f92 | Python | 9,377 | 240 | import torch
import torch.nn as nn
from torch.nn import functional as F
def inverse_transformation(adj_ori):
adj_inv = adj_ori.transpose(-1, -2)
degree_elements = torch.sum(adj_inv, dim=-1)
degree = torch.diag(degree_elements)
degree = torch.linalg.inv(degree)
adj_inv = torch.matmul(degr... |
497a918bd4a9e1940a7f05cd668e00ce87c0fe0cf33917ea12d352b152c59a96 | Python | 9,378 | 244 | import numpy as np
import os
import glob
import random
from collections import defaultdict
from itertools import chain
from rdkit import Chem
from rdkit.Chem.Scaffolds import MurckoScaffold
from sklearn.model_selection import KFold, StratifiedKFold
def create_data_split_dict_random(x_smiles,
... |
8e912c30e3a4f19fe1e6fd78a9ad259e909da8714c1c5c57a55e9b3416964811 | Python | 9,378 | 292 | from cloudvolume import CloudVolume, Storage
import numpy as np
from tqdm import tqdm
from scipy.stats.mstats import mquantiles
import io
import csv
import sys
class ContrastQuantiles():
"""Build quantiles for each section for contrast correction task to follow
"""
def __init__(self, inlayer, outlayer, x_slice, y_s... |
8d2bd4c6f12fb3da826045cd3cfee2cf8d89980d0f8c50ff32f7833d4ffb3cbb | Python | 9,379 | 266 | #!/usr/bin/env python
import sys
import re
from datetime import datetime,timedelta
import argparse
parser = argparse.ArgumentParser(description='summary nfsiostat log.')
parser.add_argument('log_file')
parser.add_argument('-s', '--start_time', help='start of effective time')
parser.add_argument('-e', '--end_time', he... |
afaa92870463f58b4e3b05c1debad5d18938113c29cc8da98c5a9d11155bee11 | Python | 9,379 | 292 | from __future__ import annotations
from dataclasses import dataclass
import numpy as np
import pandas as pd
# Absolute support gate. No reward for larger K.
MEAN_ARI_MIN = 0.70
WORST_ARI_MIN = 0.50
MEMBERSHIP_MIN = 0.70
DIM_REL_MIN = 0.70
DIM_ABS_MIN = 0.25
MIN_CLUSTER_SIZE = 5
# An isolated K has no persistence sup... |
1570f6d85593dfcc3c896957e8680226327649327c2d93875f880f8d1c0d51c7 | Python | 9,380 | 284 | import numpy as np
import torch
import torch.nn.functional as F
def as_intrinsics_matrix(intrinsics):
"""
Get matrix representation of intrinsics.
"""
K = np.eye(3)
K[0, 0] = intrinsics[0]
K[1, 1] = intrinsics[1]
K[0, 2] = intrinsics[2]
K[1, 2] = intrinsics[3]
return K
def sampl... |
042e628a1a34120868bbbea61cd8cf7df9ff3ca49f8c80525ffb85f3e7bfc185 | Python | 9,381 | 207 | import torch
from torch import nn
from torch.nn import functional as F
from torch_scatter import scatter_add, scatter_mean
from torchdrug import data
class DiffPool(nn.Module):
"""
Differentiable pooling operator from `Hierarchical Graph Representation Learning with Differentiable Pooling`_
.. _Hierarch... |
f3c68a4ca8c5a8588ea9b48305439986e6dcbf09886ecd3abe96a1e5d712e7fd | Python | 9,383 | 238 | """The maintainer-side plane fit.
``ensure_plane`` is the only fit in the package and runs on the MAINTAINER's
machine, from the tool that produces ``regtools/hemisphere/planes.json``. It
writes nothing - there is no cache to keep current and no sidecar to go stale.
``plane_for_atlas``'s shipped-table lookup is c... |
e6b525892ab48769048f26e26bd09c87359b387e4484ff4aba9384f0a35e86f1 | Python | 9,384 | 285 | import os
import math
from copy import deepcopy
from collections import deque
import xml.etree.ElementTree as ET
import numpy as np
from agents.navigation.global_route_planner import GlobalRoutePlanner
from agents.navigation.global_route_planner_dao import GlobalRoutePlannerDAO
DEBUG = False
class PIDController(obj... |
00a93bb50a388bfba8dd953a369cde20603f571bad0dcd23ee8b2186d32fcf6b | Python | 9,385 | 207 | # -*- coding: utf-8 -*-
"""
VGG-Net for CIFAR-10.
Introduction
----------------
VGG is a convolutional neural network model proposed by K. Simonyan and A. Zisserman
from the University of Oxford in the paper 鈥淰ery Deep Convolutional Networks for
Large-Scale Image Recognition鈥? .
Download Pre-trained Model
-----------... |
bb8a3b8c3418479fa1cd3c6887514fc3d013013ed412f41c6449a2f9075af19a | Python | 9,386 | 266 | """Slide SSL with SCM/VICReg pretraining script.
Copyright (c) 2024 University of Michigan. All rights reserved.
Licensed under the MIT License. See LICENSE for license information.
"""
import yaml
import logging
from functools import partial
from typing import Dict, Any, List
import torch
import pytorch_lightning ... |
11fe5938382d23a5aecd204a4cc2743133f70c6780833199773da63942e1591c | Python | 9,388 | 239 | """
Generates a ListTomoParticle object from a input STAR file
Input: - STAR file for pairing STAR files with particles and particles shapes
Output: - A ListTomoPaticles pickled object for every STAR file row
"""
################# Package import
import os
import numpy as np
import scipy as sp
import ... |
356efc9b2ec9b2fc48441aeed4a58912a1a4a29fb2cbb5aca12b3de19e46f22d | Python | 9,389 | 278 | #!/usr/bin/env python
#================================================================
# Copyright (C) 2023 Yufeng Liu (Braintell, Southeast University). All rights reserved.
#
# Filename : sdmatrix.py
# Author : Yufeng Liu
# Date : 2023-01-30
# Description :
#
#======================... |
07416e4c683251da492166b53c0d05816df0240edacd0798d9da4cebca047c5e | Python | 9,391 | 243 | import torch
import torch.nn as nn
from sklearn.metrics import jaccard_similarity_score, roc_auc_score, precision_score, f1_score, average_precision_score
import numpy as np
import dill
import time
from torch.nn import CrossEntropyLoss
from torch.optim import Adam
import os
import torch.nn.functional as F
import random... |
9166fbde2fe16e38077a571d9eeddf4421518b9c8679a7dd08b525bd857cccc8 | Python | 9,391 | 279 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.