Skip to content

Instantly share code, notes, and snippets.

@Yu-AnChen
Last active August 17, 2018 18:40
Show Gist options
  • Save Yu-AnChen/6ca7d1fa29aa7d1b6df4c63ab4ebab9b to your computer and use it in GitHub Desktop.
Save Yu-AnChen/6ca7d1fa29aa7d1b6df4c63ab4ebab9b to your computer and use it in GitHub Desktop.
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)
targetedFiles = [file for file in files if fileExt in file]
print 'Start generating ffp and dfp '
print datetime.now().strftime('%Y-%m-%d %H:%M:%S')
for file in targetedFiles:
fileName = file.split('.')[0]
print fileName
os.system("C:\Users\Public\Downloads\Fiji.app\ImageJ-win64.exe --ij2 --headless --run C:\Users\Public\Downloads\Fiji.app\plugins\imagej_basic_ashlar.py \"filename='%s.rcpnl', output_dir='.\\', experiment_name='%s'\"" %(fileName, fileName))
print 'End generating ffp and dfp '
print datetime.now().strftime('%Y-%m-%d %H:%M:%S')
files = os.listdir(dirPath)
rcpnls = ' '.join(targetedFiles)
ffps = ' '.join([file for file in files if 'ffp' in file])
dfps = ' '.join([file for file in files if 'dfp' in file])
pyramidFName = outputFileName if outputFileName else datetime.now().strftime('%Y%m%d-%H%M%S')
command = 'ashlar ' + rcpnls + ' -o .\ -f ' + pyramidFName + '.ome.tif --pyramid --ffp ' + ffps + ' --dfp ' + dfps
print 'Start stitching and generating pyramid '
print datetime.now().strftime('%Y-%m-%d %H:%M:%S')
os.system(command)
print 'End stitching and generating pyramid '
print datetime.now().strftime('%Y-%m-%d %H:%M:%S')
@Yu-AnChen
Copy link
Author

Read .csv config file with the list of slides (a slide is a folder of files from different cycles)
User run python THE_SCRIPT.py CONFIG.csv START_SLIDE_NUM END_SLIDE_NUM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment