CloseCellprofiler Module

Dear all,

First of all I want to thank to the developers and project leaders. I have used few Image Processing tools but so far, CellProfiler2 was the most intuitive.
From the first moment I got the impression that it was very complete but I found a detail missing: I couldn’t close it at the end of the pipeline.

The batch mode was not an option for me because I wanted to see all the images popping up, and open software (here by ‘open’ I mean with a visible window) dissuaded other people to use the computer after my pipeline ended.

So, I started a CloseCellProfiler module useful. I have posted it here but want to improve it.
First of all it has one only option that doesn’t make anything, because the function visible_settings(self) should return a (non-empty) list.
Secondly it is grouped into the Data Tools section because it only should run at the end of the pipeline (like the Export modules)
And latest it does sys.exit(0) that may not be appropriate.

In my case it is doing the job, may it be useful to someone else, please find it below.


‘’'Close CellProfiler closes cellprofiler

'' __version__="$Revision: 10251 $"

import os
import sys

import cellprofiler.cpmodule as cpm
import cellprofiler.pipeline as cpp
import cellprofiler.settings as cps

class CloseCellProfiler(cpm.CPModule):

module_name = 'CloseCellProfiler'
category = "Other"
variable_revision_number = 7

def create_settings(self):
    self.reallyclose = cps.Binary(
        "Really close?", True,
        doc="""Just asking!""")

def prepare_settings(self, setting_values):

def settings(self):
    """Return the settings in the order used when storing """
    result = [self.reallyclose]
    return result

def visible_settings(self):
    result = [self.reallyclose]
    return result

def run(self, workspace):
    # all of the work is done in post_run()

def post_run(self, workspace):
    '''Run the module as a data tool
    For CloseCellProfiler is very simple
    if self.reallyclose:

Thanks Reuben. We’ll look at the code and give some thought as to including it in the full release.