Commit 0b2f70c8 authored by Yi Sun's avatar Yi Sun
Browse files

new module measureimageareaoccupied

parent 18a9f523
<tool id="cp-measureimageareaoccupied" name="MeasureImageAreaOccupied Module" version="19.05">
<description>Build pipeline section MeasureImageAreaOccupied</description>
<requirements>
<requirement type="package" version="2.7.16">python</requirement>
</requirements>
<configfiles>
<inputs name="inputs" filename="input.json" />
<configfile name="script_file">
import json
import sys
import os
FOURSPACES=" "
NEWLINE="\n"
input_json_path = sys.argv[1]
input_pipeline= sys.argv[2]
params = json.load(open(input_json_path, "r"))
def writemoss():
f.write(NEWLINE)
f.write("MeasureImageAreaOccupied:[module_num:"+str(new_count)+"|svn_version:\\'Unknown\\'|variable_revision_number:4|show_window:False|notes:\\x5B\\x5D|batch_state:array(\\x5B\\x5D, dtype=uint8)|enabled:True|wants_pause:False]"+NEWLINE)
hidden = str(len(params['rpt_area']))
f.write(FOURSPACES + "Hidden:"+hidden+NEWLINE)
for area in params['rpt_area']:
f.write(FOURSPACES+"Measure the area occupied in a binary image, or in objects?:"+area['con_area']['objects_or_image']+NEWLINE)
obj_flag = area['con_area']['objects_or_image']
if obj_flag =="Objects":
f.write(FOURSPACES+"Select objects to measure:"+area['con_area']['objects_to_measure']+NEWLINE)
f.write(FOURSPACES+"Select a binary image to measure:None"+NEWLINE)
else:
f.write(FOURSPACES+"Select objects to measure:None"+NEWLINE)
f.write(FOURSPACES+"Select a binary image to measure:"+area['con_area']['image_to_measure']+NEWLINE)
with open(input_pipeline) as fin:
lines = fin.readlines()
k,v= lines[4].strip().split(':')
module_count = int(v)
new_count = module_count+1
lines[4]= k+":"+str(new_count)+"\n"
with open("output","w") as f:
f.writelines(lines)
writemoss()
f.close()
</configfile>
</configfiles>
<command><![CDATA[
python $script_file $inputs $input_pipeline
]]></command>
<inputs>
<param name="input_pipeline" type="data" label="Select pipeline file from previous moudle"/>
<repeat name="rpt_area" title="Add another area">
<conditional name="con_area">
<param name="objects_or_image" label="Measure the area occupied in a binary image, or in objects?" type="select">
<option value="Binary image">Binary image</option>
<option value="Objects">Objects</option>
</param>
<when value="Objects">
<param name="objects_to_measure" label="Select objects to measure" type="text"/>
</when>
<when value="Binary image">
<param name="image_to_measure" label="Select a binary image to measure" type="text"/>
</when>
</conditional>
</repeat>
</inputs>
<outputs>
<data name="out_file" from_work_dir="output" format="txt" hidden="false">
</data>
</outputs>
<stdio>
<exit_code range="1:" level="fatal" description="Error occured"/>
</stdio>
<tests>
</tests>
<help>
This tool builds a Cellprofiler pipeline with MeasureObjectSizeShape module
</help>
</tool>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment