Open a19s opened 3 years ago
Also linked to #18
I will likely use h5 files as a replacement. Any thoughts?
Can you please elaborate on where the issue is likely to come from? Why does the analysis go from 80MB (initial size of the image) to 90GB?
Running line:
log2 = traction_obj.process_stack(img, ref, roi=roi, verbose=1)
in the usage.ipynb notebook on Windows10 (after correcting for the shapely issue #29) gives this error
@andimi please could you post the full error message?
Can you please elaborate on where the issue is likely to come from? Why does the analysis go from 80MB (initial size of the image) to 90GB?
Because the stack is is processed in a for loop and appended to a list. For each time point in the stack a number of images are appended to this list (grayscale, tfm map, force field, roi). I'm still surprised it's getting up to 90 GB the for loop needs to be written to write to a h5 file.
i.e. in psudo code it would be on the lines of:
# pytraction/core.py
class TractionForce(object):
....
def _log_to_hdf5(target_path, log):
"""
converts defaultdict or dictionary to hdf5 file and returns path.
"""
pass
def _process_stack(self, img_stack, ref_stack, bead_channel=0, roi=False, frame=[], crop=False):
...
log['frame'].append(frame)
log['traction_map'].append(traction_map)
log['force_field'].append(f_n_m)
log['stack_bead_roi'].append(stack)
log['cell_roi'].append(cell_img_crop)
log['mask_roi'].append(mask_crop)
log['beta'].append(beta)
log['L'].append(L_optimal)
log['pos'].append(pos)
log['vec'].append(vec)
log['img_path'].append(self.img_path)
log['ref_path'].append(self.ref_path)
log['E'].append(self.E)
log['s'].append(self.s)
...
# code
self._log_to_hdf5(target_path=path, log)
Running line:
log2 = traction_obj.process_stack(img, ref, roi=roi, verbose=1)
in the usage.ipynb notebook on Windows10 (after correcting for the shapely issue #29) gives this error@andimi please could you post the full error message?
('ITERATION # ', 0)
..[DONE] (' --residual : ', 1.0000000335136763) Starting validation.. ('Validation, iteration number ', 0)
('Validation, iteration number ', 1)
('Validation, iteration number ', 2)
..[DONE]
Optimizing Lambda
Func-count x f(x) Procedure 1 381966 -235958 initial 2 618034 -227397 golden 3 236068 -245662 golden 4 145898 -255687 golden 5 90169.9 -265195 golden 6 55728.1 -273609 golden 7 34441.9 -280693 golden 8 21286.2 -286438 golden 9 13155.6 -290940 golden 10 8130.62 -294308 golden 11 5025 -296628 golden 12 3105.62 -297940 golden 13 1919.38 -298233 golden 14 1632.54 -298094 parabolic 15 2264.24 -298250 parabolic 16 2127.11 -298258 parabolic 17 2138.14 -298258 parabolic 18 2131.25 -298258 parabolic 19 2131.33 -298258 parabolic 20 2131.32 -298258 parabolic 21 2131.32 -298258 parabolic
MemoryError Traceback (most recent call last)
OK very surprising: I run the notebook 3 times and only got the error the 2nd time. It seems that it's not "reliably crashing", so it might be due to some other issues than the creation of the pandas DataFrame?
Do you have an ROI for the file?
Yes. This error came up when I was running the base notebook to check it works on Windows - I have the roi file in the example2 folder.
Yes, this is another problem now I've seen the error message.
Is this example 2 in the usage notebook? If you please could you try and run:
log2 = traction_obj.process_stack(img, ref, roi=roi, verbose=1, crop=True)
Yes, this is another problem now I've seen the error message.
Is this example 2 in the usage notebook? If you please could you try and run:
log2 = traction_obj.process_stack(img, ref, roi=roi, verbose=1, crop=True)
I ran that 3 times (with Restart Kernel and Run all cells) and it worked 100% of the time with no issues (and super fast!) :)
Great cool. Need to think about tests for this and that the default value is for the crop parameter and some restriction on large images. From the error message, we first have to do some maths on a gigantic matrix but it's possible efficiently as we can use a spares matrix but when we convert this to an array it's gigantic . I wonder if it's possible to work out the maximum input image size or adjust the mesh for the problem accordingly?
Running line:
log2 = traction_obj.process_stack(img, ref, roi=roi, verbose=1)
in the usage.ipynb notebook on Windows10 (after correcting for the shapely issue #29) gives this error