Skip to content
Snippets Groups Projects
Commit c4798863 authored by mattminder's avatar mattminder
Browse files

Extract the disappeared cells as well

parent 1c1de90f
No related branches found
No related tags found
No related merge requests found
...@@ -506,15 +506,15 @@ class App(QMainWindow): ...@@ -506,15 +506,15 @@ class App(QMainWindow):
dlg = extr.Extract(image, mask, self.reader.channel_names) dlg = extr.Extract(image, mask, self.reader.channel_names)
dlg.exec() dlg.exec()
if dlg.exit_code == 1: # Fluorescence if dlg.exit_code == 1: # Fluorescence
self.ExtractFluo(dlg.cells, dlg.outfile, dlg.file_list) self.ExtractFluo(dlg.cells, dlg.desel_cells, dlg.outfile, dlg.file_list)
elif dlg.exit_code == 2: # Mask elif dlg.exit_code == 2: # Mask
self.ExtractMask(dlg.cells, dlg.outfile) self.ExtractMask(dlg.desel_cells, dlg.outfile)
self.Enable(self.button_extractfluorescence) self.Enable(self.button_extractfluorescence)
self.ClearStatusBar() self.ClearStatusBar()
def ExtractMask(self, cell_list, outfile): def ExtractMask(self, desel_cells, outfile):
"""Extract the mask to the specified tiff file. Only take cells """Extract the mask to the specified tiff file. Only take cells
specified by the cell_list""" specified by the cell_list"""
...@@ -530,15 +530,14 @@ class App(QMainWindow): ...@@ -530,15 +530,14 @@ class App(QMainWindow):
continue continue
mask = self.reader.LoadMask(time_index, self.FOVindex) mask = self.reader.LoadMask(time_index, self.FOVindex)
all_cells = np.unique(mask) for cell in desel_cells:
for cell in set(all_cells)-set(cell_list):
mask[mask==cell] = 0 mask[mask==cell] = 0
mask_list.append(mask) mask_list.append(mask)
imageio.mimwrite(outfile, np.array(mask_list, dtype=np.uint16)) imageio.mimwrite(outfile, np.array(mask_list, dtype=np.uint16))
def ExtractFluo(self, cells_to_use, csv_filename, channel_list): def ExtractFluo(self, sel_cells, desel_cells, csv_filename, channel_list):
"""This is the function that takes as argument the filepath to the xls """This is the function that takes as argument the filepath to the xls
file and writes in the file. file and writes in the file.
It iterates over the different channels (or the sheets of the file, It iterates over the different channels (or the sheets of the file,
...@@ -601,7 +600,7 @@ class App(QMainWindow): ...@@ -601,7 +600,7 @@ class App(QMainWindow):
if val == 0: if val == 0:
continue continue
# disregard cells not in cell_list # disregard cells not in cell_list
if not (val in cells_to_use): if (val in desel_cells):
continue continue
# Calculate stats # Calculate stats
...@@ -609,6 +608,7 @@ class App(QMainWindow): ...@@ -609,6 +608,7 @@ class App(QMainWindow):
stats['Time'] = time_index stats['Time'] = time_index
stats['Channel'] = channel stats['Channel'] = channel
stats['Cell'] = val stats['Cell'] = val
stats['Disappeared'] = not (val in sel_cells)
cell_list.append(stats) cell_list.append(stats)
# Use Pandas to write csv # Use Pandas to write csv
......
...@@ -139,6 +139,7 @@ class Extract(QDialog): ...@@ -139,6 +139,7 @@ class Extract(QDialog):
self.exit_code = 1 self.exit_code = 1
self.cells = self.pc.sellist self.cells = self.pc.sellist
self.desel_cells = set(np.unique(self.pc.mask)) - set(self.cells)
self.close() self.close()
def do_cancel(self): def do_cancel(self):
...@@ -157,6 +158,7 @@ class Extract(QDialog): ...@@ -157,6 +158,7 @@ class Extract(QDialog):
self.exit_code = 2 self.exit_code = 2
self.cells = self.pc.sellist self.cells = self.pc.sellist
self.desel_cells = set(np.unique(self.pc.mask)) - set(self.cells)
self.close() self.close()
def do_sel_mult(self): def do_sel_mult(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment