Skip to content

Instantly share code, notes, and snippets.

@Yu-AnChen
Yu-AnChen / ashlar-pyramid-output-with-ffc-dfc.py
Last active August 17, 2018 18:40
Run ashlar on windows machines, output is ome-tiff with flat field and dark field corrected
import os
from datetime import datetime
dirPath = 'D:\i074_40b_132a'
outputFileName = 'i074_40b_132a'
fileExt = 'rcpnl'
os.chdir(dirPath)
files = os.listdir(dirPath)
import re
share_link = 'https://omero.hms.harvard.edu/webgateway/img_detail/559116/?c=-1|3000:45000$0000FF,-2|3000:30000$00FF00,-3|3000:30000$FFFFFF,-4|3000:30000$FF0000,-5|0:65535$0000FF,-6|2000:12000$00FF00,-7|3000:30000$FFFFFF,-8|3000:45000$FF0000,-9|3000:50000$0000FF,-10|2500:10000$00FF00,-11|500:9000$FFFFFF,-12|1500:8000$FF0000,-13|4500:45000$0000FF,-14|1500:10000$00FF00,-15|1000:4500$FFFFFF,-16|2000:10000$FF0000,17|0:65535$0000FF,18|2000:10000$00FF00,19|1500:20000$FFFFFF,20|1500:4500$FF0000,21|0:65535$0000FF,22|1500:30000$00FF00,23|3000:45000$FFFFFF,24|3000:45000$FF0000,-25|4500:55000$0000FF,-26|3000:50000$00FF00,-27|1500:45000$FFFFFF,-28|2500:25000$FF0000,-29|5000:50000$0000FF,-30|1500:4500$00FF00,-31|1000:3000$FFFFFF,-32|1500:9000$FF0000,-33|0:65535$0000FF,-34|3000:30000$00FF00,-35|2000:25000$FFFFFF,-36|3000:25000$FF0000&m=c&p=normal&ia=0&q=0.9&t=1&z=1&zm=3.1291772997934135&x=8244.978640776699&y=5880.1398058252435&maps=[{"inverted":{"enabled":false}},{"inverted":{"enabled":false}},{"inverted":{"enabl
@Yu-AnChen
Yu-AnChen / composit_color_image.py
Last active May 26, 2020 15:01 — forked from jmuhlich/melanoma_triplet_render.py
Renders RGB JPEG pyramid tiles from OME-TIFF pyramids for the melanoma triplet dataset
import numpy as np
from matplotlib import colors
from matplotlib import pyplot as plt
from PIL import Image
def composite_channel(target, image, color, range_min, range_max):
''' Render _image_ in pseudocolor and composite into _target_
Args:
target: Numpy float32 array containing composition target image
@Yu-AnChen
Yu-AnChen / YC_20180802_C1_Macro-SAVEALLCYCLES02.ijm
Last active August 10, 2018 18:15
Read .rcpnl and output 4 channel tif with subsetting capibility
// Save color hyperstack into individual tiff(4ch) & Montage with Flat-field
// 20161210 Jerry Lin
myDIR2 = getDirectory("Please enter directory");
myname = getString("Please enter image name","Tonsil1");
cs = getNumber("Enter start cycle:",0);
ce = getNumber("Enter end cycle:",12);
from __future__ import division, print_function
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from skimage.feature import match_template
import skimage.io
def getMatchedSubImg(partialImg, fullImg, debug=False):

Exemplar - run ASHLAR on demo data with the batch script

  1. Download and unzip FIJI, move the FiJji.app folder to C:\Users\Public\Downloads\

  2. Install BaSiC by following the instructions under the Install via the Fiji Updater section on this page

  3. Save the imagej_basic_ashlar.py to C:\Users\Public\Downloads\Fiji.app\plugins\

  4. Launch command prompt

# @File(label="Select a slide to process") filename
# @File(label="Select the output location", style="directory") output_dir
# @String(label="Experiment name (base name for output files)") experiment_name
# @Integer(label="Rows", value=10) rows
# @Integer(label="Columns", value=10) cols
# Takes a slide (or other multi-series BioFormats-compatible file set) and
# generates flat- and dark-field correction profile images with BaSiC. The
# output format is two multi-series TIFF files (one for flat and one for dark)
# which is the input format used by Ashlar.
from __future__ import print_function
import csv
from subprocess import call
try:
import pathlib
except ImportError:
import pathlib2 as pathlib
import argparse
import os
from ashlar import find_cycle_offset

Tools

  1. convert .rcpnl file to .ome.tif using
    bfconvert sample.rcpnl sample.ome.tif

  2. extract XML from converted .ome.tif file using
    tiffcomment sample.ome.tif > output_metadata.xml

  3. edit output_metadata.xml using text editor

@Yu-AnChen
Yu-AnChen / ashlar_thumbnail_csv_estimate_offset.py
Last active February 25, 2019 15:16
Take a csv config file and make thumbnail for all the .rcpnl files
from __future__ import print_function
import csv
from subprocess import call
try:
import pathlib
except ImportError:
import pathlib2 as pathlib
import argparse
import os
from ashlar import reg, thumbnail