Commit 3039f751 authored by Yi Sun's avatar Yi Sun
Browse files

simple pipeline works

parent 8a0a284e
<tool id="cp-common" name="Common modules" version="3.1.8">
<tool id="cp-common" name="Common modules" version="19.05">
<description>Build pipeline</description>
<requirements>
<requirement type="package" version="2.7.16">python</requirement>
......
<tool id="cp-exporttospreadsheet" name="ExportToSpreadsheet Module" version="19.05">
<description>ExportToSpreadsheet module</description>
<requirements>
<requirement type="package" version="2.7.16">python</requirement>
</requirements>
<macros>
<xml name="etss_common">
</xml>
</macros>
<configfiles>
<inputs name="inputs" filename="input.json" />
<configfile name="test">
import json
import sys
input_json_path=sys.argv[1]
as_dict = json.load(open(input_json_path, "r"))
params=json.dumps(as_dict, indent=4, sort_keys=True)
with open("output","w") as f:
f.write(params)
f.close()
</configfile>
<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 write_etss():
f.write(NEWLINE)
f.write("ExportToSpreadsheet:[module_num:6|svn_version:\\'Unknown\\'|variable_revision_number:12|show_window:True|notes:\\x5B\\x5D|batch_state:array(\\x5B\\x5D, dtype=uint8)|enabled:True|wants_pause:False]"+NEWLINE)
f.write(FOURSPACES+"Select the column delimiter:"+params["delimiter"]+NEWLINE)
f.write(FOURSPACES+"Add image metadata columns to your object data file?:"+params["add_metadata_column_to_object"]+NEWLINE)
measurement = params["con_measurement_export"]
f.write(FOURSPACES+"Select the measurements to export:"+measurement['export_measurement']+NEWLINE)
f.write(FOURSPACES+"Calculate the per-image mean values for object measurements?:"+params['calc_mean']+NEWLINE)
f.write(FOURSPACES+"Calculate the per-image median values for object measurements?:"+params['calc_median']+NEWLINE)
f.write(FOURSPACES+"Calculate the per-image standard deviation values for object measurements?:"+params['calc_standard_deviation']+NEWLINE)
f.write(FOURSPACES+"Output file location:"+params['output_file_location']+"\\x7C"+NEWLINE)
create_gene = params["con_create_gene_pattern"]["create_gene_pattern"]
if create_gene == "No":
f.write(FOURSPACES+"Create a GenePattern GCT file?:"+create_gene+NEWLINE)
f.write(FOURSPACES+"Select source of sample row name:Metadata"+NEWLINE)
f.write(FOURSPACES+"Select the image to use as the identifier:None"+NEWLINE)
f.write(FOURSPACES+"Select the metadata to use as the identifier:None"+NEWLINE)
else:
f.write(FOURSPACES+"Create a GenePattern GCT file?:"+create_gene+NEWLINE)
f.write(FOURSPACES+"Select the image to use as the identifier:None"+NEWLINE)
f.write(FOURSPACES+"Select the metadata to use as the identifier:None"+NEWLINE)
export_all_measurements = params["con_export_all_measurements"]["export_all_measurements"]
if export_all_measurements == "Yes":
f.write(FOURSPACES+"Export all measurement types?:"+export_all_measurements+NEWLINE)
f.write(FOURSPACES+"Press button to select measurements:"+NEWLINE)
f.write(FOURSPACES+"Representation of Nan/Inf:"+params["represent_nan"]+NEWLINE)
f.write(FOURSPACES+"Add a prefix to file names?:"+params["con_prefix"]["add_prefix"]+NEWLINE)
if "filename_prefix" in params["con_prefix"]:
f.write(FOURSPACES+"Filename prefix:"+params["con_prefix"]["filename_prefix"]+NEWLINE)
else:
f.write(FOURSPACES+"Filename prefix:MyPrefix_"+NEWLINE)
f.write(FOURSPACES+"Overwrite existing files without warning?:"+params["overwrite_existing_file"]+NEWLINE)
if export_all_measurements == "Yes":
f.write(FOURSPACES+"Data to export:Do not use"+NEWLINE)
f.write(FOURSPACES+"Combine these object measurements with those of the previous object?:No"+NEWLINE)
f.write(FOURSPACES+"File name:DATA.csv"+NEWLINE)
f.write(FOURSPACES+"Use the object name for the file name?:Yes"+NEWLINE)
else:
f.write(FOURSPACES+"Data to export:"+params["con_export_all_measurements"]["data_to_export"]+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)
write_etss()
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"/>
<param name="delimiter" type="select" label="Select the column delimiter">
<option value="Comma (&quot;,&quot;)">Comma (",")</option>
<option value="Tab">Tab</option>
<sanitizer sanitize="false"/>
</param>
<param name="output_file_location" type="select" label="Output file location">
<option value="Default Output Folder"/>
</param>
<conditional name="con_prefix">
<param name="add_prefix" type="select" label="Add a prefix to file names?">
<option value="Yes">Yes</option>
<option value="No">No</option>
</param>
<when value="Yes">
<param name="filename_prefix" type="text" label="Filename prefix"/>
</when>
</conditional>
<param name="overwrite_existing_file" type="select" label="Overwrite existing files without warning?">
<option value="Yes">Yes</option>
<option value="No">No</option>
</param>
<param name="add_metadata_column_to_object" type="select" label="Add image metadata columns to your object data file?">
<option value="Yes">Yes</option>
<option value="No">No</option>
</param>
<param name="represent_nan" type="select" label="Representation of Nan/Inf">
<option value="NaN">NaN</option>
<option value="Null">Null</option>
</param>
<conditional name="con_measurement_export">
<param name="export_measurement" type="select" label="Select the measurements to export">
<option value="Yes">Yes</option>
<option value="No">No</option>
</param>
<when value="Yes">
<param name="select_measurement" type="text" label="Select measurements"/>
</when>
</conditional>
<param name="calc_mean" type="select" label="Calculate the per-image mean values for object measurments">
<option value="Yes">Yes</option>
<option value="No">No</option>
</param>
<param name="calc_median" type="select" label="Calculate the per-image median values for object measurments">
<option value="Yes">Yes</option>
<option value="No">No</option>
</param>
<param name="calc_standard_deviation" type="select" label="Calculate the per-image standard deviation values for object measurments">
<option value="Yes">Yes</option>
<option value="No">No</option>
</param>
<conditional name="con_create_gene_pattern">
<param name="create_gene_pattern" type="select" label="Create a GenePattern GCT file?">
<option value="Yes">Yes</option>
<option value="No">No</option>
</param>
<when value="Yes">
<conditional name="con_source_sample_row">
<param name="select_source_sample_row_name" type="select" label="Select source of sample row name">
<option value="Metadata">Metadata</option>
<option value="Image filename">Image filename</option>
</param>
<when value="Metadata">
<param name="metadata_cat" type="select" label="Select the metadata to use as the indentifier">
<option value="None">None</option>
</param>
</when>
<when value="Image filename">
<param name="image_filename_cat" type="select" label="Select the image to use as the indentifier">
<option value="None">None</option>
</param>
</when>
</conditional>
</when>
</conditional>
<conditional name="con_export_all_measurements">
<param name="export_all_measurements" type="select" label="Export all measuremnt types?">
<option value="Yes">Yes</option>
<option value="No">No</option>
</param>
<when value="No">
<repeat name="r_data_to_export">
<param name="data_to_export" type="select" label="Data to export">
<option value="Image">Image</option>
<option value="Experiment">Experiement</option>
<option value="Object relationship">Object relationship</option>
</param>
<param name="use_as_filename" type="select" label="Use the object name for the file name?">
<option value="Yes">Yes</option>
<option value="No">No</option>
</param>
</repeat>
</when>
</conditional>
</inputs>
<outputs>
<data name="out_file" from_work_dir="output" format="txt">
</data>
</outputs>
<stdio>
<exit_code range="1:" level="fatal" description="Error occured"/>
</stdio>
<tests>
</tests>
<help>
This tool builds a Cellprofiler pipeline with just the ExportToSpreadsheet module
</help>
</tool>
<tool id="cp-identifyprimaryobjects" name="IdentifyPrimaryObjects Module" version="3.1.8">
<tool id="cp-identifyprimaryobjects" name="IdentifyPrimaryObjects Module" version="19.05">
<description>IdentifyPrimaryObject module</description>
<requirements>
<requirement type="package" version="2.7.16">python</requirement>
......@@ -8,8 +8,8 @@
<xml name="ipo_common">
<param name="input_from_nat" type="text" label="Select the input image (from NamesAndTypes)"/>
<param name="name_to_be_identified" type="text" label="Name the primary objects to be identified" />
<param name="min_diameter" type="integer" label="Typical minimum diameter of objects, in pixel units (Min)" value="15" />
<param name="max_diameter" type="integer" label="Typical maximum diameter of objects, in pixel units (Max)" value="200" />
<param name="min_diameter" type="text" label="Typical minimum diameter of objects, in pixel units (Min)" value="15" />
<param name="max_diameter" type="text" label="Typical maximum diameter of objects, in pixel units (Max)" value="200" />
<param name="discard_outside_border" type="select" label="Discard objects outside the diameter range?">
<option value="Yes">Yes</option>
......@@ -21,14 +21,6 @@
</param>
</xml>
<!-- <xml name="clumped_objects_params">
<param name="size_smoothing_filter" type="text" label="Size of smoothing filter"/>
<param name="min_allowed_distance" type="text" label="Supress local maxima that are closer than this minimum allowed distance"/>
<param name="speed_up" type="select" label="Speed up by using lower-resolution image to find local maxima?">
<option value="Yes">Yes</option>
<option value="No">No</option>
</param>
</xml> -->
<xml name="clumped_objects_params">
<conditional name="con_smoothing_filter">
<param name="smoothing_filter" type="select" label="Automatically calculate size of smoothing filter for decluping?">
......@@ -106,80 +98,142 @@ ipo = params['con_advanced']
adv = params['con_advanced']['advanced']
def write_ipo():
f.write(NEWLINE)
f.write("IdentifyPrimaryObjects:[module_num:5|svn_version:\\'Unknown\\'|variable_revision_number:13|show_window:True|notes:\\x5B\\'Identify the nuclei from the DNA channel.\\', \\'PARAMS\\x3A\\', \\'- Typical diameter of objects (Min,Max)\\', \\'- Method to distinguish clumped objects\\x3A Shape/None. With Shape, the distance between the 2 centers can be changed.\\'\\x5D|batch_state:array(\\x5B\\x5D, dtype=uint8)|enabled:True|wants_pause:False]"+NEWLINE)
if adv == "true":
f.write("Select the input image:"+ipo['input_from_nat'])
if adv == "Yes":
f.write(FOURSPACES+"Select the input image:"+ipo['input_from_nat']+NEWLINE)
f.write(FOURSPACES+"Name the primary objects to be identified:"+ipo['name_to_be_identified']+NEWLINE)
f.write(FOURSPACES+"Typical diameter of objects, in pixel units (Min,Max):"+ipo['min_diameter']+","+ipo['max_diameter']+NEWLINE)
f.write("Discard objects outside the diameter range?:"+ipo['discard_outside_border']+NEWLINE)
f.write("Discard objects touching the border of the image?:"+ipo['discard_touching_border']+NEWLINE)
f.write(FOURSPACES+"Typical diameter of objects, in pixel units (Min,Max):"+str(ipo['min_diameter'])+","+str(ipo['max_diameter'])+NEWLINE)
f.write(FOURSPACES+"Discard objects outside the diameter range?:"+ipo['discard_outside_border']+NEWLINE)
f.write(FOURSPACES+"Discard objects touching the border of the image?:"+ipo['discard_touching_border']+NEWLINE)
f.write("Method to distinguish clumped objects:"+ipo['con_distinguish_clumped_objects']['distinguish_clumped_objects']+NEWLINE)
f.write(FOURSPACES+"Method to distinguish clumped objects:"+ipo['con_distinguish_clumped_objects']['distinguish_clumped_objects']+NEWLINE)
if "con_dividing_lines" in ipo['con_distinguish_clumped_objects']:
smoothing= ipo['con_distinguish_clumped_objects']['con_dividing_lines']['con_smoothing_filter']['smothing_filter']
smoothing= ipo['con_distinguish_clumped_objects']['con_dividing_lines']['con_smoothing_filter']['smoothing_filter']
supress = ipo['con_distinguish_clumped_objects']['con_dividing_lines']['con_min_distance']['min_distance']
f.write("Method to draw dividing lines between clumped objects:"+ipo['con_distinguish_clumped_objects']['con_dividing_lines']['dividing_lines']+NEWLINE)
f.write(FOURSPACES+"Method to draw dividing lines between clumped objects:"+ipo['con_distinguish_clumped_objects']['con_dividing_lines']['dividing_lines']+NEWLINE)
if smoothing == "Yes":
f.write("Size of smoothing filter:0"+NEWLINE)
else:
f.write("Size of smoothing filter:"+ipo['con_distinguish_clumped_objects']['con_dividing_lines']['con_smoothing_filter']['size_smoothing_filter']+NEWLINE)
if smoothing == "Yes":
f.write(FOURSPACES+"Size of smoothing filter:0"+NEWLINE)
else:
f.write(FOURSPACES+"Size of smoothing filter:"+ipo['con_distinguish_clumped_objects']['con_dividing_lines']['con_smoothing_filter']['size_smoothing_filter']+NEWLINE)
if supress == "Yes":
f.write("Suppress local maxima that are closer than this minimum allowed distance:7"+NEWLINE)
else:
f.write("Suppress local maxima that are closer than this minimum allowed distance:"+ipo['con_distinguish_clumped_objects']['con_dividing_lines']['con_min_distance']['min_allowed_distance']+NEWLINE)
if supress == "Yes":
f.write(FOURSPACES+"Suppress local maxima that are closer than this minimum allowed distance:7"+NEWLINE)
else:
f.write(FOURSPACES+"Suppress local maxima that are closer than this minimum allowed distance:"+ipo['con_distinguish_clumped_objects']['con_dividing_lines']['con_min_distance']['min_allowed_distance']+NEWLINE)
f.write("Speed up by using lower-resolution image to find local maxima?:"+ipo['con_distinguish_clumped_objects']['con_dividing_lines']['speed_up']+NEWLINE)
f.write(FOURSPACES+"Speed up by using lower-resolution image to find local maxima?:"+ipo['con_distinguish_clumped_objects']['con_dividing_lines']['speed_up']+NEWLINE)
f.write("Fill holes in identified objects?:"+ipo['fill_hole']+NEWLINE)
f.write(FOURSPACES+"Fill holes in identified objects?:"+ipo['fill_hole']+NEWLINE)
if "con_dividing_lines" in ipo['con_distinguish_clumped_objects']:
f.write("Automatically calculate size of smoothing filter for declumping?:"+ ipo['con_distinguish_clumped_objects']['con_dividing_lines']['con_smoothing_filter']['smothing_filter']+NEWLINE)
f.write("Automatically calculate minimum allowed distance between local maxima?:"+ipo['con_distinguish_clumped_objects']['con_dividing_lines']['con_min_distance']['min_distance']+NEWLINE)
f.write(FOURSPACES+"Automatically calculate size of smoothing filter for declumping?:"+ ipo['con_distinguish_clumped_objects']['con_dividing_lines']['con_smoothing_filter']['smoothing_filter']+NEWLINE)
f.write(FOURSPACES+"Automatically calculate minimum allowed distance between local maxima?:"+ipo['con_distinguish_clumped_objects']['con_dividing_lines']['con_min_distance']['min_distance']+NEWLINE)
if "con_handling_excessive" in ipo:
excessive = ipo['con_handling_excessive']['excessive_handling']
excessive = ipo['con_handling_excessive']['excessive_handling']
f.write("Handling of objects if excessive number of objects identified:"+ipo['con_handling_excessive']['excessive_handling']+NEWLINE)
if excessive =="Continue":
f.write("Maximum number of objects:500"+NEWLINE)
else:
f.write("Maximum number of objects:"+ipo['con_handling_excessive']['max_obj']+NEWLINE)
f.write(FOURSPACES+"Handling of objects if excessive number of objects identified:"+ipo['con_handling_excessive']['excessive_handling']+NEWLINE)
if excessive =="Continue":
f.write(FOURSPACES+"Maximum number of objects:500"+NEWLINE)
else:
f.write(FOURSPACES+"Maximum number of objects:"+ipo['con_handling_excessive']['max_obj']+NEWLINE)
f.write(FOURSPACES+"Use advanced settings?:"+ipo['advanced']+NEWLINE)
f.write(FOURSPACES+"Threshold settings version:10"+NEWLINE)
f.write(FOURSPACES+"Threshold strategy:"+ipo['con_threshold_strategy']['threshold_strategy']+NEWLINE)
threshold_method=ipo['con_threshold_method']['threshold_method']
f.write(FOURSPACES+"Thresholding method:"+threshold_method+NEWLINE)
f.write(FOURSPACES+"Threshold smoothing scale:"+str(ipo['threshold_smoothing_scale'])+NEWLINE)
f.write(FOURSPACES+"Threshold correction factor:"+str(ipo['threshold_correction_factor'])+NEWLINE)
f.write(FOURSPACES+"Lower and upper bounds on threshold:"+ str(ipo['threshold_lower']) +","+ str(ipo['threshold_upper'])+NEWLINE)
if threshold_method == "Manual":
f.write(FOURSPACES+"Manual threshold:"+str(ipo['con_threshold_method']['manual_threshold'])+NEWLINE)
else:
f.write(FOURSPACES+"Manual threshold:0"+NEWLINE)
if threshold_method == "Measurement":
f.write(FOURSPACES+"Select the measurement to threshold with:"+ipo['con_threshold_method']['threshold_measurement']+NEWLINE)
else:
f.write(FOURSPACES+"Select the measurement to threshold with:None"+NEWLINE)
threshold_class = ipo['con_threshold_method']['con_threshold_class']['threshold_class']
f.write(FOURSPACES+"Two-class or three-class thresholding?:"+threshold_class+NEWLINE)
if threshold_class == "Three classes":
f.write(FOURSPACES+"Assign pixels in the middle intensity class to the foreground or the background?:"+threshold_class['assign_pixel']+NEWLINE)
else:
f.write(FOURSPACES+"Assign pixels in the middle intensity class to the foreground or the background?:Foreground"+NEWLINE)
if ipo['con_threshold_strategy']['threshold_strategy'] == "Adaptive":
f.write(FOURSPACES+"Size of adaptive window:"+ipo['con_threshold_strategy']['adaptive_window']+NEWLINE)
else:
f.write(FOURSPACES+"Size of adaptive window:500"+NEWLINE)
if threshold_method == "RobustBackground":
f.write(FOURSPACES+"Lower outlier fraction:"+ipo['con_threshold_method']['lower_outlier_fraction']+NEWLINE)
f.write(FOURSPACES+"Upper outlier fraction:"+ipo['con_threshold_method']['upper_outlier_fraction']+NEWLINE)
f.write(FOURSPACES+"Averaging method:"+ipo['con_threshold_method']['avg_method']+NEWLINE)
f.write(FOURSPACES+"Variance method:"+['variance_method']+NEWLINE)
f.write(FOURSPACES+"# of deviations:"+ipo['con_threshold_method']['no_of_deviations']+NEWLINE)
else:
f.write(FOURSPACES+"Lower outlier fraction:0.05"+NEWLINE)
f.write(FOURSPACES+"Upper outlier fraction:0.05"+NEWLINE)
f.write(FOURSPACES+"Averaging method:Mean"+NEWLINE)
f.write(FOURSPACES+"Variance method:Standard deviation"+NEWLINE)
f.write(FOURSPACES+"# of deviations:2.0"+NEWLINE)
f.write(FOURSPACES+"Thresholding method:"+threshold_method+NEWLINE) #This is a repeated entry, but needed for pipeline file
with open(input_pipeline) as fin:
lines = fin.readlines()
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)
write_ipo()
f.close()
</configfile>
</configfiles>
<command><![CDATA[
python $test $inputs
#python $script_file $inputs $input_pipeline
python $script_file $inputs $input_pipeline
]]></command>
<inputs>
<param name="input_pipeline" type="data" label="Select pipeline file from previous moudle"/>
<conditional name="con_advanced">
<param name="advanced" type="boolean" label="Use advanced settings?" />
<when value="false">
<param name="advanced" type="select" label="Use advanced settings?">
<option value="No">No</option>
<option value="Yes">Yes</option>
</param>
<when value="No">
<expand macro="ipo_common" />
</when>
<when value="true">
<when value="Yes">
<expand macro="ipo_common" />
<conditional name="con_threshold_strategy">
<param name="threshold_strategy" type="select" label="Threshold strategy">
......@@ -215,6 +269,20 @@ f.close()
<when value="Manual">
<param name="manual_threshold" type="text" label="Manual threshold" />
</when>
<when value="RobustBackground">
<param name="lower_outlier_fraction" type="float" value="0.05" label="Lower outlier fraction" />
<param name="upper_outlier_fraction" type="float" value="0.05" label="Upper outlier fraction" />
<param name="avg_method" type="select" label="Averaging method">
<option value="Mean">Mean</option>
<option value="Median">Median</option>
<option value="Mode">Mode</option>
</param>
<param name="variance_method" type="select" label="Variance">
<option value="Standard deviation">Standard deviation</option>
<option value="Median absolute deviation">Median absolute deviation</option>
</param>
<param name="no_of_deviations" type="float" value="2.0" label="# of deviations" />
</when>
</conditional>
<param name="threshold_smoothing_scale" type="float" value="0.0" label="Threshold smoothing scale"/>
<param name="threshold_correction_factor" type="float" value="0.0" label="Threshold correction factor"/>
......
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