Skip to content

Instantly share code, notes, and snippets.

@T4mmi
T4mmi / gocadascii.py
Created November 14, 2022 09:15
Python reader for GOCAD ASCII exports
# -*- coding: utf-8 -*-
import re
import warnings
from collections import namedtuple
from pathlib import Path
"""GOCAD Object file template:
GOCAD <type> <version>
HEADER {
@T4mmi
T4mmi / batch_rotate.ijm
Last active March 27, 2023 17:21
Batch rotate image AND ImageJ markers
macro "Batch rotate images and annotations" {
/* Read images in a chosen directory and rotate them along
with the annotations (points) and store them inplace */
source_dir = getDirectory("Choose an input Directory "); // window to select the input directory
dest_dir = getDirectory("Choose an output Directory "); // window to select the output directory
list = getFileList(source_dir); // list files in it
angle = getNumber("choose the clockwise rotation angle", 90);
setBatchMode(true); // activate batch process
@T4mmi
T4mmi / labels.py
Last active March 22, 2019 09:02
labeling function using simple flood fill algorithm
import numpy as np
from numba import jit
from typing import Sequence
# @jit(nopython=True)
def flood_fill_labels(data: np.ndarray, seeds: Sequence[Sequence[int]]=[]) -> np.ndarray:
"""Labels an array using a flood fill algorithm
The function implements a flooding algorithm
considering a connectivity equals to the 2*data.ndim
@T4mmi
T4mmi / Thickness3D.remote.cmake
Last active February 11, 2019 08:11
Proposal for ITK remote module cmake conf
# Contact: Thomas Janvier <thomas.p.janvier@gmail.com>
itk_fetch_module(Thickness3D
"Tools for 3D thickness measurement"
GIT_REPOSITORY ${git_protocol}://github.com/InsightSoftwareConsortium/ITKBinaryThinning3D.git
GIT_TAG <TODO: add the latest valid commit tag found on https://github.com/InsightSoftwareConsortium/ITKThickness3D/commits/master>
)
@T4mmi
T4mmi / batch_export_xy_coordinates.ijm
Last active July 20, 2021 17:15
Batch export ImageJ markers coordinates from TIFF metadata
macro "Batch export XY coordinates" {
/* Read images in a chosen directory and export measurements
XY coordinates (in pixels) in a .txt file with the same name */
dir = getDirectory("Choose a Directory "); // window to select the input directory
list = getFileList(dir); // list files in it
setBatchMode(true); // activate batch process
for (i=0; i<list.length; i++) { // loop over files
showProgress(i, list.length); // update progressbar
file_name = list[i];