Skip to content

Instantly share code, notes, and snippets.

@Yu-AnChen
Yu-AnChen / imageJ_basic_ashlar_ffp_only.py
Last active March 19, 2020 18:28 — forked from jmuhlich/imagej_basic_ashlar.py
ImageJ BaSiC shading correction script for use with Ashlar
# @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
# @Float(label="Flat field smoothing parameter (0 for automatic)", value=0.1) lambda_flat
# @Float(label="Dark field smoothing parameter (0 for automatic)", value=0.01) lambda_dark
# 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.
import pytiff
import skimage.io
try:
import pathlib
except ImportError:
import pathlib2 as pathlib
import argparse
import warnings
import sys

The following instructions take you through setting up a SSH Key on O2. (Official instructions for generating SSH key)

The senario behind this is that in CyCIF pipeline, it is designed to first submit a job to transfer files from /n/files, get the job ID, and the following steps in the pipeline are dependent on the transfer job.

And the SSH Key allows you to transfer files from /n/files using the transfer server with ssh rsync, without being prompted for password. So that you can put ssh rsync from n/files to /n/scratch2 into an sbatch script. And the job could hang until the transfer is complete, then it will run the rest of the script.

Note: Replace your_ecommons with your ecommons while you type in the commands.


@Yu-AnChen
Yu-AnChen / deepzoom_tile.py
Last active August 12, 2019 15:24
Setting up openslide on Windows machines to generate cycif-viewer compatible pyramid tiles
#
# deepzoom_tile - Convert whole-slide images to Deep Zoom format
#
# Copyright (c) 2010-2015 Carnegie Mellon University
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of version 2.1 of the GNU Lesser General Public License
# as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful, but
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 bin_rcpnl_module import *
@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

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

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
# @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.

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