Skip to content
This repository has been archived by the owner on Nov 26, 2023. It is now read-only.

Commit

Permalink
see #59 checkbox for keeping memmap in caiman viewer modules
Browse files Browse the repository at this point in the history
  • Loading branch information
kushalkolar committed Jul 1, 2021
1 parent 266dd5b commit 0b884e7
Show file tree
Hide file tree
Showing 12 changed files with 1,289 additions and 20 deletions.
11 changes: 6 additions & 5 deletions mesmerize/viewer/modules/batch_run_modules/CNMF.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ def run(batch_dir: str, UUID: str):
except Exception as e:
output.update({'status': 0, 'output_info': traceback.format_exc()})

for mf in glob(os.path.join(batch_dir, f'memmap-{UUID}*')):
try:
os.remove(mf)
except:
pass
if not input_params.get('keep_memmap', False):
for mf in glob(os.path.join(batch_dir, f'memmap-{UUID}*')):
try:
os.remove(mf)
except:
pass

end_time = time()
proc_time = (end_time - start_time) / 60
Expand Down
11 changes: 6 additions & 5 deletions mesmerize/viewer/modules/batch_run_modules/CNMFE.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,12 @@ def run(batch_dir: str, UUID: str):

dview.terminate()

for mf in glob(batch_dir + '/memmap-*'):
try:
os.remove(mf)
except: # Windows doesn't like removing the memmaps
pass
if not input_params.get('keep_memmap', False):
for mf in glob(batch_dir + '/memmap-*'):
try:
os.remove(mf)
except: # Windows doesn't like removing the memmaps
pass

end_time = time()
processing_time = (end_time - start_time) / 60
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def run_single(batch_dir, UUID, output):

fname = [file_path + '_input.tiff']
# TODO: Should just unpack the input params as kwargs
input_params = pickle.load(open(file_path + '.params', 'rb'))
input_params: dict = pickle.load(open(file_path + '.params', 'rb'))
mc_kwargs = input_params['mc_kwargs']

splits_rig = n_processes
Expand Down Expand Up @@ -130,11 +130,12 @@ def run_single(batch_dir, UUID, output):

output.update({'status': 1, 'bord_px': int(bord_px_els)})

for mf in glob(os.path.join(batch_dir, UUID + '*.mmap')):
try:
os.remove(mf)
except:
pass
if not input_params.get('keep_memmap', False):
for mf in glob(os.path.join(batch_dir, UUID + '*.mmap')):
try:
os.remove(mf)
except:
pass

dview.terminate()

Expand Down
2 changes: 2 additions & 0 deletions mesmerize/viewer/modules/caiman_motion_correction.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ def get_params(self, group_params: bool = False) -> dict:
else:
d.update({**mc_params})

d['keep_memmap'] = self.ui.checkBoxKeepMemmap.isChecked()

return d

def add_to_batch_elas_corr(self):
Expand Down
3 changes: 2 additions & 1 deletion mesmerize/viewer/modules/cnmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ def get_params(self, *args, group_params: bool = False) -> dict:
'item_name': self.ui.lineEdName.text(),
'refit': self.ui.checkBoxRefit.isChecked(),
'border_pix': bord_px,
'is_3d': is_3d
'is_3d': is_3d,
'keep_memmap': self.ui.checkBoxKeepMemmap.isChecked()
}

# Group the kwargs of the two parts seperately
Expand Down
2 changes: 2 additions & 0 deletions mesmerize/viewer/modules/cnmfe.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ def get_params(self, item_type: str, group_params: bool = False) -> dict:
else:
raise ValueError("Must specify argument `item_type` as either 'corr_pnr' or 'cnmfe'")

d['keep_memmap'] = self.ui.checkBoxKeepMemmap.isChecked()

return d

def add_to_batch_corr_pnr(self, params: dict = None) -> UUID:
Expand Down

Large diffs are not rendered by default.

429 changes: 429 additions & 0 deletions mesmerize/viewer/modules/pytemplates/cnmf_pytemplate.py

Large diffs are not rendered by default.

480 changes: 480 additions & 0 deletions mesmerize/viewer/modules/pytemplates/cnmfe_pytemplate.py

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions mesmerize/viewer/modules/ui_files/caiman_motion_correction.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>287</width>
<height>842</height>
<width>279</width>
<height>869</height>
</rect>
</property>
<property name="floating">
Expand Down Expand Up @@ -507,6 +507,13 @@ Use single quotes for strings, do not use double quotes.</string>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBoxKeepMemmap">
<property name="text">
<string>Keep memmap</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_20">
<item>
Expand Down Expand Up @@ -609,8 +616,11 @@ Use single quotes for strings, do not use double quotes.</string>
<tabstop>sliderOverlaps</tabstop>
<tabstop>btnShowQuilt</tabstop>
<tabstop>spinboxUpsample</tabstop>
<tabstop>checkBoxKeepMemmap</tabstop>
<tabstop>lineEditNameElastic</tabstop>
<tabstop>btnAddToBatchElastic</tabstop>
<tabstop>comboBoxProjectionsOption</tabstop>
<tabstop>pushButtonViewProjections</tabstop>
</tabstops>
<resources/>
<connections>
Expand Down
10 changes: 9 additions & 1 deletion mesmerize/viewer/modules/ui_files/cnmf_pytemplate.ui
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ Use single quotes for strings, do not use double quotes.</string>
<string/>
</property>
<property name="title">
<string>Use additional CNMF params</string>
<string>&amp;Use additional CNMF params</string>
</property>
<property name="checkable">
<bool>true</bool>
Expand Down Expand Up @@ -800,6 +800,13 @@ Use single quotes for strings, do not use double quotes</string>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBoxKeepMemmap">
<property name="text">
<string>Keep memmap</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
Expand Down Expand Up @@ -849,6 +856,7 @@ Use single quotes for strings, do not use double quotes</string>
<tabstop>groupBox_eval_kwargs</tabstop>
<tabstop>plainTextEdit_eval_kwargs</tabstop>
<tabstop>checkBoxRefit</tabstop>
<tabstop>checkBoxKeepMemmap</tabstop>
<tabstop>lineEdName</tabstop>
<tabstop>btnAddToBatchCNMF</tabstop>
</tabstops>
Expand Down
8 changes: 8 additions & 0 deletions mesmerize/viewer/modules/ui_files/cnmfe_pytemplate.ui
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,13 @@ Use single quotes for strings, do not use double quotes</string>
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxKeepMemmap">
<property name="text">
<string>Keep memmap</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
Expand Down Expand Up @@ -927,6 +934,7 @@ Use single quotes for strings, do not use double quotes</string>
<tabstop>doubleSpinBoxDecayTime</tabstop>
<tabstop>groupBox_eval_kwargs</tabstop>
<tabstop>plainTextEdit_eval_kwargs</tabstop>
<tabstop>checkBoxKeepMemmap</tabstop>
<tabstop>lineEdName</tabstop>
<tabstop>btnAddToBatchCNMFE</tabstop>
</tabstops>
Expand Down

0 comments on commit 0b884e7

Please sign in to comment.