keyword stringclasses 7
values | repo_name stringlengths 8 98 | file_path stringlengths 4 244 | file_extension stringclasses 29
values | file_size int64 0 84.1M | line_count int64 0 1.6M | content stringlengths 1 84.1M ⌀ | language stringclasses 14
values |
|---|---|---|---|---|---|---|---|
3D | jianlin-cheng/TransFun | preprocessing/generate_msa.py | .py | 10,510 | 205 | import os, subprocess
from typing import Any, Mapping, MutableMapping, Optional, Sequence, Union
from absl import logging
from tools import jackhmmer, parsers, residue_constants, msa_identifiers, hhblits
import numpy as np
import shutil
from absl import app
from absl import logging
import multiprocessing
from glob impo... | Python |
3D | jianlin-cheng/TransFun | plots/protein_structure.py | .py | 2,489 | 117 | # import networkx as nx
# import numpy as np
# import matplotlib.pyplot as plt
# from mpl_toolkits.mplot3d import Axes3D
# from biopandas.pdb import PandasPdb
import random
import networkx as nx
import Constants
from Dataset.Dataset import load_dataset
import matplotlib.pyplot as plt
kwargs = {
'prot_ids': ['P83... | Python |
3D | jianlin-cheng/TransFun | Dataset/Dataset.py | .py | 10,101 | 234 | import math
import os
import pickle
import subprocess
import torch
import os.path as osp
from torch_geometric.data import Dataset, download_url, HeteroData
import Constants
from Dataset.distanceTransform import myDistanceTransform
from Dataset.myKnn import myKNNGraph
from Dataset.myRadiusGraph import myRadiusGraph
fro... | Python |
3D | jianlin-cheng/TransFun | Dataset/myRadiusGraph.py | .py | 1,158 | 34 | from typing import Optional
import torch_geometric
from torch_geometric.transforms import RadiusGraph
class myRadiusGraph(RadiusGraph):
r"""Creates edges based on node positions :obj:`pos` to all points within a
given distance.
"""
def __init__(
self,
name: str,
r: float,
... | Python |
3D | jianlin-cheng/TransFun | Dataset/__init__.py | .py | 0 | 0 | null | Python |
3D | jianlin-cheng/TransFun | Dataset/AdjacencyTransform.py | .py | 1,915 | 49 | import torch
from torch_geometric.transforms import BaseTransform
class AdjacencyFeatures(BaseTransform):
r"""Saves the Euclidean distance of linked nodes in its edge attributes.
Args:
norm (bool, optional): If set to :obj:`False`, the output will not be
normalized to the interval :math:... | Python |
3D | jianlin-cheng/TransFun | Dataset/distanceTransform.py | .py | 1,246 | 37 | import torch
from torch_geometric.transforms import Distance
class myDistanceTransform(Distance):
r"""
"""
def __init__(self, edge_types, norm=True, max_value=None, cat=True):
super().__init__(norm, max_value, cat)
self.edge_types = edge_types
def __call__(self, data):
for ... | Python |
3D | jianlin-cheng/TransFun | Dataset/utils.py | .py | 4,610 | 143 | import math
import os
import re
import subprocess
from pathlib import Path
import pickle
import numpy as np
import torch
from biopandas.pdb import PandasPdb
import torch.nn.functional as F
from keras.utils import to_categorical
from keras_preprocessing.sequence import pad_sequences
import Constants
from Constants imp... | Python |
3D | jianlin-cheng/TransFun | Dataset/myKnn.py | .py | 1,123 | 31 | import torch_geometric
from torch_geometric.transforms import KNNGraph
from torch_geometric.utils import to_undirected
class myKNNGraph(KNNGraph):
r"""Creates a k-NN graph based on node positions :obj:`pos`.
"""
def __init__(self, name: str, k=6, loop=False, force_undirected=False,
flow='... | Python |
3D | twni2016/Elastic-Boundary-Projection | nii2npy.py | .py | 2,073 | 54 | import os
import numpy as np
import nibabel as nib
import shutil
import argparse
parser = argparse.ArgumentParser(description='EBP')
parser.add_argument('--data_path', type=str, default=None, help='data path')
data_path = args.data_path
images_list = os.listdir(os.path.join(data_path, 'imagesTr'))
labels_list = os.lis... | Python |
3D | twni2016/Elastic-Boundary-Projection | data_generation.py | .py | 13,911 | 344 | import os
import time
import numpy as np
from scipy.spatial import cKDTree
import argparse
PAD = 10
MAX_EUCLID = 10
MAX_MANHAT = int(np.ceil(np.sqrt(3) * MAX_EUCLID)) + 2
MAX_VALUE = MAX_MANHAT + 2
ITER_TH = 10
HEIGHT = 120
WIDTH = 120
STEP = 6 # for x,y axis
STEP_Z = 3 # due to small z_len
INIT_D = 5.0
CT_INF = -125
... | Python |
3D | twni2016/Elastic-Boundary-Projection | test_util.py | .py | 5,929 | 145 | import os
import time
import numpy as np
from sklearn.neighbors.kde import KernelDensity
from scipy.spatial import Delaunay, distance
from scipy.ndimage.morphology import binary_fill_holes
import trimesh
import fast_functions as ff
# for KDE_tri(). may be tuned
KDE_bandwidth = 1.0
KDE_log_prob_th = -14
# for mesh3d().... | Python |
3D | twni2016/Elastic-Boundary-Projection | vnetg_data_load.py | .py | 2,552 | 58 | import torch
import torch.utils.data as data
from data_generation import *
# npy shape (ITER_TH, SLICES + IN_SLICE + 2, HEIGHT, WIDTH)
# total samples ITER_TH * len(npy_list)
class EBP(data.Dataset):
def __init__(self, train, data_path, folds, current_fold, organ_id, slices):
self.train = train
self.data_path = ... | Python |
3D | twni2016/Elastic-Boundary-Projection | fast_functions.py | .py | 2,882 | 104 | # This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.8
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
from sys import version_info
if version_info >= (2, 6, 0):
def swig_import_helper():
from os.path imp... | Python |
3D | twni2016/Elastic-Boundary-Projection | test_voxel.py | .py | 8,072 | 194 | from queue import *
from test_iter import *
from test_util import *
# for find_target_component(). may be tuned
DSC_TH = 0.60
TARGET_RATIO = 0.10
# for remove_by_D_value()
NONZERO_TH = 10000
MEAN_TH = 2.0
def set_sphere_projection():
'''initialize the (x,y,z) unit sphere coordinate'''
direction_x = np.zeros((HEIGH... | Python |
3D | twni2016/Elastic-Boundary-Projection | vnetg.py | .py | 9,361 | 231 | import os
import time
import numpy as np
import argparse
import torch
import torch.nn as nn
from vnetg_data_load import *
def arg_parser():
parser = argparse.ArgumentParser(description='EBP')
parser.add_argument('--data_path', type=str, default=None, help='data path')
parser.add_argument('--gpu_id', type=int, defau... | Python |
3D | twni2016/Elastic-Boundary-Projection | test_iter.py | .py | 15,860 | 360 | from vnetg import Vnet
from data_generation import *
ITER_TH = 11 # may be tuned
POINT_STEP = 3
EPSILON = 0.00001
INTER_DSC_TH = 0.99
def arg_parser():
parser = argparse.ArgumentParser(description='EBP')
parser.add_argument('--data_path', type=str, default=None)
parser.add_argument('--organ_id', type=int, default... | Python |
3D | twni2016/Elastic-Boundary-Projection | run.sh | .sh | 1,627 | 55 | # Elastic Boundary Projection for 3D Medical Image Segmentation, CVPR 2019
# Author: Tianwei Ni.
# turn on these switches to execute each module
ENABLE_DATA_DOWNLOAD=0
ENABLE_DATA_GENERATION=0
ENABLE_TRAINING=0
ENABLE_TESTING=0
DATA_PATH='/mnt/data0/tianwei/EBP_MD_Spleen/'
GPU_ID=0
CURRENT_FOLD=0
FOLDS=1
ORGAN_ID=1
... | Shell |
3D | potpov/New-Maxillo-Dataset-Segmentation | train.py | .py | 4,043 | 108 | import torch
import logging
from tqdm import tqdm
from torch import nn
import torchio as tio
import torch.distributed as dist
def train2D(model, train_loader, loss_fn, optimizer, epoch, writer, evaluator, phase='Train'):
model.train()
evaluator.reset_eval()
losses = []
for i, (images, labels, names, ... | Python |
3D | potpov/New-Maxillo-Dataset-Segmentation | alpha_shape.py | .py | 5,430 | 153 | import json
from hull.voxelize.voxelize import voxelize
from scipy.spatial import Delaunay
import numpy as np
from collections import defaultdict
from scipy.ndimage import binary_fill_holes
import os
import pathlib
from glob import glob
def alpha_shape_3D(pos, alpha):
"""
Compute the alpha shape (concave hull... | Python |
3D | potpov/New-Maxillo-Dataset-Segmentation | eval.py | .py | 6,275 | 142 | from statistics import mean
import torch
import pathlib
import numpy as np
from skimage import metrics
import os
import pandas as pd
import zipfile
class Eval:
def __init__(self, loader_config, project_dir, skip_dump=False):
self.iou_list = []
self.dice_list = []
self.config = loader_config... | Python |
3D | potpov/New-Maxillo-Dataset-Segmentation | losses.py | .py | 5,505 | 133 | import numpy as np
import torch
from torch import nn
import torch.nn.functional as F
class JaccardLoss(torch.nn.Module):
def __init__(self, weight=None, size_average=True, per_volume=False, apply_sigmoid=False,
min_pixels=5):
super().__init__()
self.size_average = size_average
... | Python |
3D | potpov/New-Maxillo-Dataset-Segmentation | augmentations.py | .py | 12,560 | 347 | import importlib
from torchvision import transforms
import numpy as np
import torch
from scipy.ndimage import rotate, map_coordinates, gaussian_filter
import torchvision.transforms.functional as TF
import cv2
from torch.nn.functional import interpolate
class ToPilImage:
def __init__(self):
pass
def _... | Python |
3D | potpov/New-Maxillo-Dataset-Segmentation | model.py | .py | 2,730 | 73 | import torch
import torch.nn as nn
class Competitor(nn.Module):
def __init__(self, n_classes):
super(Competitor, self).__init__()
self.ec0 = self.conv3Dblock(1, 32)
self.ec1 = self.conv3Dblock(32, 32)
self.ec2 = self.conv3Dblock(32, 64, kernel_size=3, stride=2) # third dimension... | Python |
3D | potpov/New-Maxillo-Dataset-Segmentation | dataset.py | .py | 5,843 | 131 | import numpy as np
import os
from tqdm import tqdm
import logging
import torchio as tio
import utils
import random
class Loader3D():
def __init__(self, config, do_train=True, additional_dataset=False, is_competitor=False, skip_primary=False):
self.config = config
self.subjects = {
'... | Python |
3D | potpov/New-Maxillo-Dataset-Segmentation | test.py | .py | 4,470 | 99 | import torch
from torch import nn
from tqdm import tqdm
from torch.nn.functional import interpolate
from augmentations import CenterCrop
import numpy as np
import torchio as tio
import logging
from utils import resample
import cc3d
def test(model, test_loader, epoch, writer, evaluator, phase):
model.eval()
... | Python |
3D | potpov/New-Maxillo-Dataset-Segmentation | utils.py | .py | 7,777 | 196 | from torch.utils.data import DistributedSampler
from scipy.ndimage import binary_fill_holes
import pathlib
import torchio as tio
import logging
import os
import numpy as np
import yaml
import sys
import torch
from tqdm import tqdm
import SimpleITK as sitk
import json
from scipy.linalg import norm
def set_logger(log_p... | Python |
3D | potpov/New-Maxillo-Dataset-Segmentation | main.py | .py | 7,912 | 193 | import argparse
import os
import pathlib
import torch.utils.data as data
from torch.utils.tensorboard import SummaryWriter
import utils
from eval import Eval as Evaluator
from losses import LossFn
from test import test
import sys
import numpy as np
from os import path
import socket
import random
from torch.backends imp... | Python |
3D | potpov/New-Maxillo-Dataset-Segmentation | hull/__init__.py | .py | 0 | 0 | null | Python |
3D | potpov/New-Maxillo-Dataset-Segmentation | hull/smoother.py | .py | 2,171 | 62 | import numpy as np
from scipy import spatial as sp_spatial
from hull.voxelize.voxelize import voxelize
from visualize_results import MultiView
from matplotlib import pyplot as plt
from scipy.ndimage import binary_fill_holes
from scipy.ndimage.morphology import binary_erosion
def delaunay(volume):
coords = np.argw... | Python |
3D | potpov/New-Maxillo-Dataset-Segmentation | hull/voxelize/__init__.py | .py | 51 | 3 | __author__ = 'Peter Hofmann'
__version__ = '0.0.5'
| Python |
3D | potpov/New-Maxillo-Dataset-Segmentation | hull/voxelize/voxelize.py | .py | 7,000 | 185 | import argparse
import sys
import math
import numpy as np
from tqdm import tqdm
from .common.progressbar import print_progress_bar
from .voxelintersect.triangle import Triangle, t_c_intersection, INSIDE, vertexes_to_c_triangle, triangle_lib
from .mesh import get_scale_and_shift, scale_and_shift_triangle
class Bounda... | Python |
3D | potpov/New-Maxillo-Dataset-Segmentation | hull/voxelize/mesh.py | .py | 1,333 | 45 | import numpy as np
# functions are loosly based
def get_scale_and_shift(mesh, resolution):
"""
@type mesh: list[((float, float, float), (float, float, float), (float, float, float))]
@type resolution: int
@rtype: (float, list[float], int)
"""
triangle_count = 0
mins = list(mesh[0][0])
... | Python |
3D | potpov/New-Maxillo-Dataset-Segmentation | hull/voxelize/voxelintersect/__init__.py | .py | 29 | 2 | __author__ = 'Peter Hofmann'
| Python |
3D | potpov/New-Maxillo-Dataset-Segmentation | hull/voxelize/voxelintersect/triangle.py | .py | 14,805 | 450 | import sys
import os
import numpy as np
from ctypes import cdll, Structure, c_float
class Point3(Structure):
_fields_ = [
("x", c_float),
("y", c_float),
("z", c_float)
]
class Triangle3(Structure):
_fields_ = [
("v1", Point3),
("v2", Point3),
("v3", P... | Python |
3D | potpov/New-Maxillo-Dataset-Segmentation | hull/voxelize/voxelintersect/triangleCube.c | .c | 12,166 | 325 | /* Original file:
* https://github.com/erich666/GraphicsGems/blob/master/gemsiii/triangleCube.c
* Some optimisations for use in voxelisation have been made
*/
#include <math.h>
/* this version of SIGN3 shows some numerical instability, and is improved
* by using the uncommented macro that follows, and a different... | C |
3D | potpov/New-Maxillo-Dataset-Segmentation | hull/voxelize/voxelintersect/LICENSE.md | .md | 706 | 5 | LICENSE
This code repository predates the concept of Open Source, and predates most licenses along such lines. As such, the official license truly is:
EULA: The Graphics Gems code is copyright-protected. In other words, you cannot claim the text of the code as your own and resell it. Using the code is permitted in an... | Markdown |
3D | potpov/New-Maxillo-Dataset-Segmentation | hull/voxelize/common/progressbar.py | .py | 1,102 | 25 | # Print iterations progress
# https://stackoverflow.com/questions/3173320/text-progress-bar-in-the-console
import sys
def print_progress_bar(iteration, total, prefix='', suffix='', decimals=1, length=20, fill='='):
"""
Call in a loop to create terminal progress bar
@params:
iteration - Required ... | Python |
3D | potpov/New-Maxillo-Dataset-Segmentation | hull/voxelize/common/__init__.py | .py | 29 | 2 | __author__ = 'Peter Hofmann'
| Python |
3D | potpov/New-Maxillo-Dataset-Segmentation | hull/voxelize/meshlib/mtlreader.py | .py | 7,545 | 222 | import os
import sys
class Texture(object):
"""
@type file_path: str
@type origin: (float, float, float)
@type stretch: (float, float, float)
@type turbulence: (float, float, float)
"""
def __init__(self):
self.file_path = ""
self.origin = (0.0, 0.0, 0.0)
self.stret... | Python |
3D | potpov/New-Maxillo-Dataset-Segmentation | hull/voxelize/meshlib/stlreader.py | .py | 6,739 | 208 | import numpy as np
import os
from struct import unpack
from .defaultreader import DefaultReader
class StlReader(DefaultReader):
"""
@type _facets: dict[str, list[tuple[tuple[float]]]]
@type _norms: dict[str, list[tuple[float]]]
"""
def __init__(self):
self._facets = {}
self._norms... | Python |
3D | potpov/New-Maxillo-Dataset-Segmentation | hull/voxelize/meshlib/__init__.py | .py | 51 | 3 | __author__ = 'Peter Hofmann'
__version__ = "0.0.4"
| Python |
3D | potpov/New-Maxillo-Dataset-Segmentation | hull/voxelize/meshlib/defaultreader.py | .py | 705 | 41 | class DefaultReader(object):
"""
Mesh Reader Prototype
"""
def read_archive(self, file_path):
"""
@type file_path: str
@rtype: None
"""
pass
def read(self, file_path):
"""
@type file_path: str
@rtype: None
"""
pass
... | Python |
3D | potpov/New-Maxillo-Dataset-Segmentation | hull/voxelize/meshlib/objreader.py | .py | 15,405 | 428 | import tempfile
import zipfile
import shutil
import sys
import os
from .defaultreader import DefaultReader
class MeshGroup(object):
"""
# group name
g [group name]
# Vertices
v 0.123 0.234 0.345 1.0
# Texture coordinates
vt 0.500 1 [0]
# Vertex normals
vn 0.707 0.00... | Python |
3D | potpov/New-Maxillo-Dataset-Segmentation | hull/voxelize/meshlib/meshreader.py | .py | 1,938 | 64 | import os
from .defaultreader import DefaultReader
from .stlreader import StlReader
from .objreader import ObjReader
class MeshReader(DefaultReader):
"""
@type _type_reader: dict[str, any]
@type _reader: DefaultReader
"""
_type_reader = {
".stl": StlReader,
".obj": ObjReader,
... | Python |
3D | jstnmchl/xraySimulator | getDefaultParams.m | .m | 844 | 30 | function [ dp ] = getDefaultParams()
%GETDEFAULTSCENEPARAMS Summary of this function goes here
% Detailed explanation goes here
%TODO Generates default parameters for x-ray simulation that are
%independent of the phantom being imaged (e.g. detector size, source location,
%etc.). Also creates template to be modified ... | MATLAB |
3D | jstnmchl/xraySimulator | xraySimulator.m | .m | 11,533 | 398 | function [ image ] = xraySimulator(stlFilename, attenCoeffs, outputImgFilename, params, varargin )
%XRAYSIMULATOR Simulates x-ray images of one or more objects (STL files)
% created by an x-ray point source and a rectangular x-ray detector. The
% resulting simulation is visualized in a 3D plot and the simulated ... | MATLAB |
3D | jstnmchl/xraySimulator | 3rdParty/textprogressbar/textprogressbar.m | .m | 2,043 | 61 | function textprogressbar(c)
% This function creates a text progress bar. It should be called with a
% STRING argument to initialize and terminate. Otherwise the number correspoding
% to progress in % should be supplied.
% INPUTS: C Either: Text string to initialize or terminate
% Percentage... | MATLAB |
3D | jstnmchl/xraySimulator | 3rdParty/textprogressbar/demo_textprogressbar.m | .m | 321 | 16 | %demo_textprogressbar
%This a demo for textprogressbar script
textprogressbar('calculating outputs: ');
for i=1:100,
textprogressbar(i);
pause(0.1);
end
textprogressbar('done');
textprogressbar('saving data: ');
for i=1:0.5:80,
textprogressbar(i);
pause(0.05);
end
textprogressbar('terminated')... | MATLAB |
3D | jstnmchl/xraySimulator | 3rdParty/TriangleRayIntersection/PointInsideVolume.m | .m | 1,366 | 37 | function inside = PointInsideVolume(point, faces, vertices)
%% Point within the volume test
% TriangleRayIntersection is a low level function which can be used to
% solve higher level problems. For example a test to see if point is inside
% or outside of a volume defined by a continous surface:
%% chack input
if nargi... | MATLAB |
3D | jstnmchl/xraySimulator | 3rdParty/stlTools/stlPlot.m | .m | 640 | 24 | function stlPlot(v, f, name)
%STLPLOT is an easy way to plot an STL object
%V is the Nx3 array of vertices
%F is the Mx3 array of faces
%NAME is the name of the object, that will be displayed as a title
figure;
object.vertices = v;
object.faces = f;
patch(object,'FaceColor', [0.8 0.8 1.0], ...
'EdgeColo... | MATLAB |
3D | jstnmchl/xraySimulator | 3rdParty/stlTools/stlRead.m | .m | 401 | 13 | function [v, f, n, name] = stlRead(fileName)
%STLREAD reads any STL file not depending on its format
%V are the vertices
%F are the faces
%N are the normals
%NAME is the name of the STL object (NOT the name of the STL file)
format = stlGetFormat(fileName);
if strcmp(format,'ascii')
[v,f,n,name] = stlReadAscii(fileNa... | MATLAB |
3D | jstnmchl/xraySimulator | 3rdParty/stlTools/stlDemo.m | .m | 1,340 | 40 | %% STLDEMO shows how to use the functions included in the toolbox STLTOOLS
%% EXAMPLE 1.- How to cut a sphere and close the base to get a semisphere
% load an ascii STL sample file (STLGETFORMAT and STLREADASCII)
[vertices,faces,normals,name] = stlRead('sphere300faces.stl');
stlPlot(vertices,faces,name);
% the spher... | MATLAB |
3D | jstnmchl/xraySimulator | 3rdParty/stlTools/stlReadBinary.m | .m | 2,257 | 60 | function [v, f, n, name] = stlReadBinary(fileName)
%STLREADBINARY reads a STL file written in BINARY format
%V are the vertices
%F are the faces
%N are the normals
%NAME is the name of the STL object (NOT the name of the STL file)
%=======================
% STL binary file format
%=======================
% Binary STL ... | MATLAB |
3D | jstnmchl/xraySimulator | 3rdParty/stlTools/stlAddVerts.m | .m | 644 | 15 | function [vnew, fnew] = stlAddVerts(v, f, list)
%STLADDVERTS adds new vertices (and consequently, new faces) to a STL object
%V is the Nx3 array of vertices
%F is the Mx3 array of faces
%LIST is the list of vertices to be added to the object
%VNEW is the new array of vertices
%FNEW is the new array of faces
% triangul... | MATLAB |
3D | jstnmchl/xraySimulator | 3rdParty/stlTools/stlWrite.m | .m | 10,034 | 252 | function stlWrite(filename, varargin)
%STLWRITE Write STL file from patch or surface data.
%
% STLWRITE(FILE, FV) writes a stereolithography (STL) file to FILE for a
% triangulated patch defined by FV (a structure with fields 'vertices'
% and 'faces').
%
% STLWRITE(FILE, FACES, VERTICES) takes faces and verti... | MATLAB |
3D | jstnmchl/xraySimulator | 3rdParty/stlTools/stlGetFormat.m | .m | 1,687 | 38 | function format = stlGetFormat(fileName)
%STLGETFORMAT identifies the format of the STL file and returns 'binary' or
%'ascii'
fid = fopen(fileName);
% Check the file size first, since binary files MUST have a size of 84+(50*n)
fseek(fid,0,1); % Go to the end of the file
fidSIZE = ftell(fid); % Check the size... | MATLAB |
3D | jstnmchl/xraySimulator | 3rdParty/stlTools/stlDelVerts.m | .m | 805 | 26 | function [vnew, fnew] = stlDelVerts(v, f, list)
%STLDELVERT removes a list of vertices from STL files
%V is the Nx3 array of vertices
%F is the Mx3 array of faces
%LIST are the vertices (rows) to delete, where length(LIST) < N
%VNEW is the new array of vertices
%FNEW is the new array of faces
% find (on the global set... | MATLAB |
3D | jstnmchl/xraySimulator | 3rdParty/stlTools/stlSlimVerts.m | .m | 879 | 30 | function [vnew, fnew]= stlSlimVerts(v, f)
% PATCHSLIM removes duplicate vertices in surface meshes.
%
% This function finds and removes duplicate vertices.
%
% USAGE: [v, f]=patchslim(v, f)
%
% Where v is the vertex list and f is the face list specifying vertex
% connectivity.
%
% v contains the vertices for all trian... | MATLAB |
3D | jstnmchl/xraySimulator | 3rdParty/stlTools/stlReadAscii.m | .m | 1,604 | 56 | function [v, f, n, name] = stlReadAscii(fileName)
%STLREADASCII reads a STL file written in ASCII format
%V are the vertices
%F are the faces
%N are the normals
%NAME is the name of the STL object (NOT the name of the STL file)
%======================
% STL ascii file format
%======================
% ASCII STL files h... | MATLAB |
3D | jstnmchl/xraySimulator | 3rdParty/stlTools/stlGetVerts.m | .m | 1,067 | 31 | function list = stlGetVerts(v, f, mode)
%GETVERTS returns the vertices that are 'opened' or 'closed' depending on
%the 'mode'. An 'open' vertice is the one that defines an open side. An
%open side is the one that only takes part of one triangle
%V is the Nx3 array of vertices
%F is the Mx3 array of faces
%MODE can be... | MATLAB |
3D | jstnmchl/xraySimulator | 3rdParty/in_polyhedron/in_polyhedron_test.m | .m | 4,080 | 90 | %% Tutorial and tests of IN_POLYHEDRON function
% *By Jarek Tuszynski* (jaroslaw.w.tuszynski@leidos.com)
%
% IN_POLYHEDRON tests if points are inside a 3D triangulated surface
% (faces/vertices) or volume (tetrahedrals/vertices). There are NO
% assumptions about orientation of the face normals.
%
% IN = INPOLYHEDRON(X... | MATLAB |
3D | jstnmchl/xraySimulator | 3rdParty/in_polyhedron/in_polyhedron.m | .m | 6,666 | 145 | function inside = in_polyhedron(varargin)
%% Point within the volume test
%IN_POLYHEDRON Tests if points are inside a 3D triangulated surface
% (faces/vertices) or volume (tetrahedrals/vertices). There is NO
% assumption about orientation of the face normals.
%
% IN = IN_POLYHEDRON(X,POINTS) tests if the query poin... | MATLAB |
3D | jstnmchl/xraySimulator | 3rdParty/SpinCalc/SpinCalc.m | .m | 20,640 | 409 | function OUTPUT=SpinCalc(CONVERSION,INPUT,tol,ichk)
%Function for the conversion of one rotation input type to desired output.
%Supported conversion input/output types are as follows:
% 1: Q Rotation Quaternions
% 2: EV Euler Vector and rotation angle (degrees)
% 3: DCM Orthogonal DCM Rotation M... | MATLAB |
3D | aafkegros/MicroscopyNodes | mkdocs_macros.py | .py | 984 | 29 | from pathlib import Path
def define_env(env):
@env.macro
def youtube(video_id, width=360, height=200):
return f'''
<div class="yt-lazy" data-id="{video_id}" style="width:{width}px; height:{height}px;">
<div class="yt-thumbnail" style="background-image: url('https://img.youtube.com/vi/{video_id}/... | Python |
3D | aafkegros/MicroscopyNodes | build.py | .py | 5,369 | 176 | import glob
import os
import subprocess
import sys
from dataclasses import dataclass
from typing import List, Union
# import bpy
import tomlkit
toml_path = "microscopynodes/blender_manifest.toml"
whl_path = "./microscopynodes/wheels"
blender_path ="/Users/oanegros/Documents/blenderBuilds/stable/blender-4.5.3-macos-ar... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/parse_inputs.py | .py | 5,670 | 143 | import bpy
import numpy as np
from pathlib import Path
from .ui import preferences
from .handle_blender_structs import *
from .file_to_array import load_array, selected_array_option
from .ui.preferences import addon_preferences
def get_cache_dir():
if addon_preferences().cache_option == 'TEMPORARY':
path... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/__init__.py | .py | 2,828 | 84 | # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/load.py | .py | 5,406 | 144 | import bpy
from pathlib import Path
import numpy as np
from .handle_blender_structs import *
from .handle_blender_structs import dependent_props
from .load_components import *
from .parse_inputs import *
from .file_to_array import load_array, arr_shape
from mathutils import Matrix
def load_threaded(params):
try... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/handle_blender_structs/dependent_props.py | .py | 2,461 | 74 | import bpy
from bpy.props import (StringProperty, FloatProperty,
PointerProperty, IntProperty,
BoolProperty, EnumProperty
)
# update functions are defined locally
from ..file_to_array import change_path, change_channel_ax, change_array_option, get... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/handle_blender_structs/progress_handling.py | .py | 93 | 6 | import bpy
def log(string):
bpy.context.scene.MiN_progress_str = string
return None
| Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/handle_blender_structs/__init__.py | .py | 147 | 5 | from .collection_handling import *
from .node_handling import *
from .progress_handling import *
from .props import *
from .array_handling import * | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/handle_blender_structs/node_handling.py | .py | 5,525 | 160 | import bpy
from .. import min_nodes
import re
def get_nodes_last_output(group):
# fast function for tests and non-user changed trees
try:
output = group.nodes['Group Output']
except:
output = group.nodes['Material Output']
try:
last = output.inputs[0].links[0].from_node
... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/handle_blender_structs/array_handling.py | .py | 823 | 23 | import numpy as np
import dask.array as da
def take_index(imgdata, indices, dim, axes_order):
if dim in axes_order:
return da.take(imgdata, indices=indices, axis=axes_order.find(dim))
return imgdata
def len_axis(dim, axes_order, shape):
if dim in axes_order:
return shape[axes_order... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/handle_blender_structs/props.py | .py | 4,026 | 134 | import bpy
from bpy.props import (StringProperty, FloatProperty,
PointerProperty, IntProperty,
BoolProperty, EnumProperty
)
import platform
from enum import Enum
import tempfile
class min_keys(Enum):
NONE = 0
AXES = 1
VOLUME = 2
... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/handle_blender_structs/collection_handling.py | .py | 2,361 | 63 | import bpy
def get_collection(name, supercollections=[], duplicate=False, under_active_coll=False):
# duplicate is not duplicated-name-safe, so intention is to have types of names with/without duplication (programmer's choice)
coll = bpy.context.scene.collection
lcoll = bpy.context.view_layer.layer_collect... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/file_to_array/tif.py | .py | 1,795 | 47 | from .arrayloading import ArrayLoader
from .arrayoptions import add_array_option
import tifffile
class TifLoader(ArrayLoader):
suffixes = ['.tif', '.TIF', '.tiff', '.TIFF']
def set_file_globals(self, input_file):
with tifffile.TiffFile(input_file) as ifstif:
self._set_axes_order(ifstif.ser... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/file_to_array/__init__.py | .py | 2,784 | 72 | from .tif import TifLoader
from .zarr import ZarrLoader
from .arrayoptions import ArrayOption, get_array_options, selected_array_option
from ..handle_blender_structs.progress_handling import log
import bpy
CLASSES = [ArrayOption]
LOADERS = [TifLoader, ZarrLoader]
def get_loader():
for Loader in LOADERS:
lo... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/file_to_array/arrayloading.py | .py | 8,615 | 199 | import bpy
from pathlib import Path
import numpy as np
import dask.array as da
from .arrayoptions import copy_array_option, selected_array_option
from ..handle_blender_structs import len_axis
MAX_BLENDER_SIZE_GIB = 4
class ArrayLoader():
# the suffixes of the file path
suffix = [None]
# callback function... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/file_to_array/arrayoptions.py | .py | 4,222 | 130 | import bpy
import numpy as np
class ArrayOption(bpy.types.PropertyGroup):
identifier: bpy.props.IntProperty()
# NOTE: rescaled xy_size and z_size by MiN rescaling is done elsewhere.
xy_size: bpy.props.FloatProperty()
z_size: bpy.props.FloatProperty()
# for generated scales
is_rescaled: bpy.pr... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/file_to_array/zarr.py | .py | 4,641 | 124 | from .arrayloading import ArrayLoader
from ..handle_blender_structs.progress_handling import log
import numpy as np
import zarr
import json
import os
import bpy
from pathlib import Path
from urllib.parse import urljoin
from .arrayoptions import copy_array_option
import s3fs
OME_ZARR_V_0_4_KWARGS = dict(dimension_separ... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/ui/__init__.py | .py | 176 | 8 | from . import ops
from . import channel_list
from . import panel
from . import preferences
CLASSES = ops.CLASSES + channel_list.CLASSES + panel.CLASSES + preferences.CLASSES
| Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/ui/ops.py | .py | 4,144 | 124 | import bpy
from .. import load
from .. import parse_inputs
from .. import handle_blender_structs
from .channel_list import *
from bpy.types import (Panel,
Operator,
AddonPreferences,
PropertyGroup,
)
from bpy.types import UI... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/ui/preferences.py | .py | 7,450 | 178 | import bpy
from .. import __package__
from bpy.props import StringProperty, BoolProperty, EnumProperty
from pathlib import Path
import tempfile
import yaml
class MicroscopyNodesPreferences(bpy.types.AddonPreferences):
from .ui.channel_list import ChannelDescriptor
bl_idname = __package__
def set_channels... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/ui/channel_list.py | .py | 4,369 | 95 | import bpy
from bpy.types import UIList
import os
# from ..min_nodes.shader_nodes import draw_category_menus
def update_ix(self, context):
context.scene.MiN_ch_index = self.ix
class ChannelDescriptor(bpy.types.PropertyGroup):
# Initialization of these classes is done in set_channels - these defaults are not... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/ui/panel.py | .py | 5,926 | 147 | import bpy
from ..handle_blender_structs.dependent_props import *
from ..file_to_array import selected_array_option
from .preferences import addon_preferences
class TIFLoadPanel(bpy.types.Panel):
bl_idname = "SCENE_PT_zstackpanel"
bl_label = "Microscopy Nodes"
bl_space_type = 'PROPERTIES'
bl_region_typ... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/load_components/load_labelmask.py | .py | 9,969 | 249 | import numpy as np
import bpy
import bmesh
from pathlib import Path
import json
import os
from ..handle_blender_structs import *
from .load_generic import *
from .. import min_nodes
class LabelmaskIO(DataIO):
min_type = min_keys.LABELMASK
def dissolve(self, obj, obj_id):
m = obj.data
bm = bme... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/load_components/load_volume.py | .py | 18,486 | 427 | import bpy
from mathutils import Color
from pathlib import Path
import numpy as np
import math
import itertools
from .load_generic import *
from ..handle_blender_structs import *
from .. import min_nodes
NR_HIST_BINS = 2**16
def get_leading_trailing_zero_float(arr):
min_val = max(np.argmax(arr > 0)-1, 0) / ... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/load_components/__init__.py | .py | 169 | 6 | from .load_generic import *
from .load_axes import *
from .load_labelmask import *
from .load_volume import *
from .load_surfaces import *
from .load_slice_cube import * | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/load_components/load_axes.py | .py | 9,508 | 240 | import bpy
import numpy as np
from pathlib import Path
from ..handle_blender_structs import *
from .. import min_nodes
def load_axes(size_px, pixel_size, scale, scale_factor, axes_obj=None, container=None):
if axes_obj is not None:
mod = get_min_gn(axes_obj)
update_axes(mod, size_px, pixel_size, s... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/load_components/load_slice_cube.py | .py | 1,546 | 34 | import bpy
from .. import handle_blender_structs
import numpy as np
def load_slice_cube(size_px, scale, scale_factor, container, slicecube=None):
if slicecube is None:
bpy.ops.mesh.primitive_cube_add(location=size_px*scale/2)
slicecube = bpy.context.active_object
slicecube.name = "slice cub... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/load_components/load_surfaces.py | .py | 5,457 | 129 | import bpy
from .load_generic import *
from ..handle_blender_structs import *
from .. import min_nodes
class SurfaceIO(DataIO):
def import_data(self, ch, scale):
if min_keys.VOLUME in ch['collections']:
return ch['collections'][min_keys.VOLUME], ch['metadata'][min_keys.VOLUME]
fro... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/load_components/load_generic.py | .py | 8,309 | 218 | import bpy, bpy_types
from ..handle_blender_structs import *
import numpy as np
def ChannelObjectFactory(min_key, obj):
if min_key == min_keys.VOLUME:
from .load_volume import VolumeObject
return VolumeObject(obj)
elif min_key == min_keys.SURFACE:
from .load_surfaces import SurfaceObje... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/min_nodes/nodeSliceCube.py | .py | 3,105 | 81 | import bpy
from .nodeElementWiseCompare import element_wise_compare_node_group
def slice_cube_node_group():
node_group = bpy.data.node_groups.get("Slice Cube")
if node_group:
return node_group
node_group = bpy.data.node_groups.new(type = 'ShaderNodeTree', name = "Slice Cube")
links = node_grou... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/min_nodes/nodeScale.py | .py | 8,406 | 190 | import bpy
import numpy as np
from .nodeScaleBox import scalebox_node_group
from .nodeGridVerts import grid_verts_node_group
from .nodesBoolmultiplex import axes_demultiplexer_node_group
#initialize scale node group
def scale_node_group():
node_group = bpy.data.node_groups.get("Scale bars (arbitrary pixel unit)")
... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/min_nodes/__init__.py | .py | 414 | 11 | from .nodeScale import scale_node_group
from .nodesBoolmultiplex import axes_multiplexer_node_group
from .nodeCrosshatch import crosshatch_node_group
from .nodeGridVerts import grid_verts_node_group
from .nodeScaleBox import scalebox_node_group
from .nodeBoundedMapRange import bounded_map_range_node_group
from .nodeSli... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/min_nodes/nodeElementWiseCompare.py | .py | 1,763 | 46 | import bpy
def element_wise_compare_node_group(operation):
node_group = bpy.data.node_groups.get(f"Element-wise {operation}")
if node_group:
return node_group
node_group = bpy.data.node_groups.new(type = 'ShaderNodeTree', name = f"Element-wise {operation}")
links = node_group.links
interfa... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/min_nodes/nodeCrosshatch.py | .py | 2,644 | 63 | import bpy
def crosshatch_node_group():
node_group = bpy.data.node_groups.get("crosshatch")
if node_group:
return node_group
node_group = bpy.data.node_groups.new(type = 'GeometryNodeTree', name = "crosshatch")
links = node_group.links
interface = node_group.interface
interface.new_so... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/min_nodes/nodeBoundedMapRange.py | .py | 2,376 | 54 | import bpy
# UNUSED currently
# This is a reskin of Map Range node to make it easier to understand for novice users
# by removing things unnecessary for microscopy data, and bounding values to microscopynodes
# ranges
def bounded_map_range_node_group():
node_group = bpy.data.node_groups.get("Bounded Map Range")
... | Python |
3D | aafkegros/MicroscopyNodes | microscopynodes/min_nodes/nodeGridVerts.py | .py | 4,471 | 113 | import bpy
def grid_verts_node_group():
node_group = bpy.data.node_groups.get("_grid_verts")
if node_group:
return node_group
node_group= bpy.data.node_groups.new(type = 'GeometryNodeTree', name = "_grid_verts")
links = node_group.links
interface = node_group.interface
# -- get IO ... | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.