Open dfgdgdfgd opened 1 year ago
Hi Mario, no problem at all, the more issues we solve, the better it is for all the users.
So the reason why you cannot access some functions is that you opened 3D segmentation and not all the functions are functional in 3D segmentation yet. By 3D segmentation I mean that also the segmentations masks have z-slices, while in 2D segmentation you need to choose a z-slice or a projection to segment.
However, I am not sure that this was what you intended to do. The error is connected to that, so first I need to understand what you want to achieve.
Did you segment this in the GUI (module 3) or in the segmentation module (module 2)?
Do you want to segment only a specific z-slice (or projection) or every single z-slice?
Hi Francesco,
thanks for the fast response! I used first the segmentation module 2. Now i tried to segment the 3D data within module 3, but with the same result. In principle i want to segment the whole 3D stack (Cellpose does it slice by slice and stitch the masks at the end together, if i understood right?). For me, the most charming feature of ACDC at the moment is the easy use of getting 3D single cell segmentation features without programming knowledge.
Ok great, if that is what you wanted to achieve then you are on the right track. And yes, Cellpose can do both full 3D segmentation and slice-by-slice with stitching. They recommended the slice-by-slice anyway, so that is also the right approach in my opinion.
However, I cannot replicate the error you had and I cannot think of an obvious way why it would be triggered. The fastest way is that I experiment with the same data that you have.
Do you have the chance to zip and send me the Position folder you are testing with? You can upload it to google drive and share it with my email padovaf@tcd.ie or make it public until I download it and then you can delete it.
For the functions that are not yet available in 3D, the plan is to implement them together with the users (depending on what they need to achieve) because these functions need to be entirely repurposed depending on what the user wants to achieve. For example, should the "delete cell" delete the entire 3D object or only the z-slice? It might be that we need both functionalities, so probably a key modifier (like holding the control key) would be a solution.
Long story short, if there is a disabled function that you would like to use for 3D segmentation let me know and I can implement it soon.
Cheers, Francesco
I sent you an email with the 3D dataset i used, thanks for trying!!
"Long story short, if there is a disabled function that you would like to use for 3D segmentation let me know and I can implement it soon."
That´s a great offer, thanks, but i don´t want to exaggerate it too much.... ;) At the moment i would be very happy to get at least the most common features in 3D (like e.g. volume, intensities, volume of whole spheroid, etc...), to quantify the efficiacy of drug treatments.
By the way, not sure, if it´s already possible, since i could not save the readouts, but a really important feature for me would be to quantify staining intensities between cytoplasm and nucleus. I already segmented in Cellpose the cytoplasm (using a membran staining) and nucleus. But does ACDC offer the possibility to measure intensities within cytoplasm and nucleus in 3D?
Best Mario
Ok cool, I got your data, I will be testing it soon and get back to you when I fix it.
And don't worry about exaggerating, the best thing we can do is to keep things in the pipeline, and GitHub issues is the best way for me. So don't be afraid and open an issue for any feature you would like to see implemented.
Anyway, for your staining question, it is actually possible to do it (new feature added very recently), because another user asked a similar question.
However, it is not well documented yet, so I will explain it here. In Cell-ACDC you can segment as many channels (different stainings) as you want. When you run the segmentation module for example it asks you to append a name to the segmentation file, so for example you could segment the nucleus and append the name nucleus
. This way acdc will save a segmentation file ending with segm_nucleus.npz
. When you then load this segmentation file and compute the metrics acdc will create a connected file called acdc_output_nucleus.csv
which is a table with all the numerical features.
You can then repeat the same process for the cytoplasm staining and append for example cyto
. At this point do not worry about the IDs of the cytoplasm segmentation masks because they don't match with the corresponding nucleus yet.
To match the IDs you need to run the new utility that you can find from the Utilities
menu on the top menubar of the little launcher that opens when you launch acdc. The utility is called Track sub-cellular objects (assign same ID as the cell they belong to)...
. Once you launch this utility you can follow the instructions in the pop-ups. First you choose the cyto
file as representative of the cells and then you choose the nucleus segmentation file.
At the end of the process, acdc will create a new segmentation file that is the same as the nucleus segm file but with each nucleus that has the same ID of the cell it belongs to (tracked).
You can now load this segmentation file in the GUI and compute numerical features. The Cell_ID
in the table of the tracked nucleus will be the same Cell_ID
in the table of the cyto
file.
At this point the analysis becomes specific to your case (depending on what quantities you want to calculate between cyto and nucleus), so you are going to need to process the two files acdc_output_cyto.csv
and acdc_output_nucleus_tracked.csv
with your own software of choice (Excel, MATLAB, Python etc.). For example, you can take the mean intensity of the nucleus and compare it to the mean intensity of the cytoplasm (possibilities at this point are endless :D).
Note that if you know Python (or plan to learn it soon) we also have Jupyter notebooks for downstream analysis of the numerical features (like for example combining features from multiple segmentation files), so in that case, we can help you set up your own analysis.
Small note, this new utility was never tested with 3D segmentation so I will do that with your data soon.
I hope it's clear enough and I hope it can be helpful with what you want to achieve.
Cheers, Francesco
Now that I think about it you gave me an idea for a new feature. The possibility to combine metrics between different segmentation files using the combine measurements window. Essentially you would combine measurements using a GUI calculator. You can track the progress of this feature in issue #170
Salve Francesco,
great to hear that, thanks! As I have already written, your software has great potential, especially if you could get all the features to work in 3D as well. The majority of biologists have no or rudimentary programming skills to create a custom subsequent analysis, so an analysis tool like ACDC would be a huge help for many researchers. And many thanks for the detailed instruction. I will try this out as soon as the analysis in 3D is possible.
Regarding your new idea......indeed, you should keep an eye on this feature, since it is in general an important readout for many biological questions
ciao, Mario
Hi Mario, I'm happy to hear that you think Cell-ACDC can be useful, that's the main reason I developed it :D
Anyway, I released v1.2.4rc46
which has a couple of bug fixes for 3D segmentation. You should be able to save metrics with your dataset. Furthermore you can also track sub-cellular objects also in 3D now.
Please, update with pip install --upgrade cellacdc
(after activating the environment) and let me know if it works, thanks!
Cheers, Francesco
Hi Francesco,
works perfect now, thanks!! Tomorrow i will test it with different settings. But i encountered a new issue with a 3D masks.tiff i segmented directly in Cellpose and converted using your utility to _segm.npz. I imported the _segm.npz file into the GUI, tried to save it and received the following issue:
============================== Traceback (most recent call last): File "D:\Programme\Anaconda3\envs\acdc\lib\site-packages\cellacdc\gui.py", line 1122, in run acdc_df = self.addMetrics_acdc_df( File "D:\Programme\Anaconda3\envs\acdc\lib\site-packages\cellacdc\gui.py", line 664, in addMetrics_acdc_df metrics_values[bkgr_key][i] = np.quantile( File "<__array_function__ internals>", line 180, in quantile File "D:\Programme\Anaconda3\envs\acdc\lib\site-packages\numpy\lib\function_base.py", line 4412, in quantile return _quantile_unchecked( File "D:\Programme\Anaconda3\envs\acdc\lib\site-packages\numpy\lib\function_base.py", line 4424, in _quantile_unchecked r, k = _ureduce(a, File "D:\Programme\Anaconda3\envs\acdc\lib\site-packages\numpy\lib\function_base.py", line 3725, in _ureduce r = func(a, *kwargs) File "D:\Programme\Anaconda3\envs\acdc\lib\site-packages\numpy\lib\function_base.py", line 4593, in _quantile_ureduce_func result = _quantile(arr, File "D:\Programme\Anaconda3\envs\acdc\lib\site-packages\numpy\lib\function_base.py", line 4704, in _quantile previous = np.take(arr, previous_indexes, axis=DATA_AXIS) File "<__array_function__ internals>", line 180, in take File "D:\Programme\Anaconda3\envs\acdc\lib\site-packages\numpy\core\fromnumeric.py", line 190, in take return _wrapfunc(a, 'take', indices, axis=axis, out=out, mode=mode) File "D:\Programme\Anaconda3\envs\acdc\lib\site-packages\numpy\core\fromnumeric.py", line 57, in _wrapfunc return bound(args, **kwds) IndexError: cannot do a non-empty take from an empty axes.
Should i send you the 3D file?
Thanks and best Mario
Hi Mario, since this error doesn't seem to be related to saving the metrics I created the new issue #172 for easier tracking of the problem.
I will close this issue if you don't mind but feel free to reopen it if you have additional problems with the metrics.
I will look into the error you had with the conversion later today.
Cheers, Francesco
Hi Mario, I reopen this because I didn't understand that your error was still about saving metrics. I closed the other wrong issue, sorry for the confusion.
Ok, now I understood why I was confused. The error that you copy pasted is about saving metrics in the GUI, but the error in the screenshot is saving metrics from the utility, right? I think the easiest is that you zip the Position folder and send it to me for testing. Send it to my email padovaf@tcd.ie if you can, thanks!
Just a curiosity, I tried segmenting with cellpose GUI but I cannot find how to save the masks as .tif file. I tried saving as seg.npy but it doesn't work. How did you save them as tif from cellpose?
Just a curiosity, I tried segmenting with cellpose GUI but I cannot find how to save the masks as .tif file. I tried saving as seg.npy but it doesn't work. How did you save them as tif from cellpose?
Never mind, I understood how. The menu in the cellpose GUI says "Save as PNG" but it actually saves them as .tif and not .png :D
Hi Francesco, you have to choose >save as .png<, obviously it´s a writting bug.... ;) I will send you the requested data tomorrow, before i will try again to be sure that i didn´t made something wrong...
Ciao Mario
ok, you were faster.... ;)
Hi Francesco, it´s me again, sorry ;) I got a new error, when saving additional metrics using the ACDC output i sent you:
Traceback (most recent call last): File "D:\Programme\Anaconda3\envs\acdc\lib\site-packages\cellacdc\gui.py", line 893, in addMetrics_acdc_df rp_table = skimage.measure.regionprops_table( File "D:\Programme\Anaconda3\envs\acdc\lib\site-packages\skimage\measure_regionprops.py", line 996, in regionprops_table return _props_to_dict( File "D:\Programme\Anaconda3\envs\acdc\lib\site-packages\skimage\measure_regionprops.py", line 790, in _props_to_dict rp = getattr(r, prop) File "D:\Programme\Anaconda3\envs\acdc\lib\site-packages\skimage\measure_regionprops.py", line 526, in axis_minor_length return sqrt(10 * (-ev[0] + ev[1] + ev[2])) ValueError: math domain error
Furthermore, i was not able to load the corresponding fluorescence tiff, could you maybe try it, maybe i did something wrong?
By the way....just to understand it, but do i need the raw tiff to measure e.g intensities or is this information already in the segmentation?
Thanks & Best Mario
ValueError: math domain error
Hi Mario, that error is an error from the library (called skimage.measure.regionprops_table
) that Cell-ACDC uses to compute some of the metrics.
Specifically, some of the objects in the segmentation file cause an error when trying to calculate their axis_minor_length
, probably because it is a single pixel object or some artefact.
It would be nice if the library did not raise an error but simply reported a null value, but for now, that's not the case.
If you are not interested in the axis_minor_length
you can ignore that error.
However, with this error, I think all of the other morphological properties computed by that library are not saved (like solidity, elongation etc.), so you might want to repeat the metrics computation without the axis_minor_length
property. To do that untick the axis_minor_length
from the computed measurements (see the dialogue in the menu Measurements --> Set measurements
). Note that this dialogue also contains explanations for each one of the saved metrics.
Furthermore, i was not able to load the corresponding fluorescence tiff, could you maybe try it, maybe i did something wrong?
I will try sure.
By the way....just to understand it, but do i need the raw tiff to measure e.g intensities or is this information already in the segmentation?
You need to have the file in the same Position folder yes. Then you should load it before saving the metrics. There are multiple ways to load the fluorescent signal:
File --> Load fluorescent images....
Set measurements
dialogue (see the menu Measurements --> Set measurements
)Overlay channels' images
which is the button on the top toolbar with this iconLet me know if it's not clear. In the meantime, I will test with your data and let you know.
Cheers, Francesco
Hi Mario,
I released v1.2.4rc48
where I changed the way Cell-ACDC handles the errors on morphological properties. Instead of skipping all properties if only one gives an error, now the ones that raise errors (like axis_minor_length
in your dataset) will be saved with a null value.
Please, activate the acdc
environment and then install the latest version with the command pip install --upgrade cellacdc
.
Let me know if it works! Thanks.
Cheers, Francesco
Hi Francesco,
works perfect, many thanks!
Best Mario
Great, I will close this issue then. Note that I added a comment to #170 since we referenced that issue here and the new release should also have a solution for #170. Let me know there if it works (when you have time of course).
Cheers, Francesco
Hi Francesco, i wanted to try the new feature, but unfortunatly i encountered again a similar error while saving additional metrices from the segmented YAP channel (the same i sent you before). The nuclei channel can be saved without problems. Do you have an idea what´s wrong now? Is it maybe, because i created just to test a combined measurement set which may cause this error? By the way, how can i erase a self defined combined measurement?
Traceback (most recent call last): File "D:\Programme\Anaconda3\envs\acdc\lib\site-packages\cellacdc\myutils.py", line 54, in inner_function result = func(self, *args, *kwargs) File "D:\Programme\Anaconda3\envs\acdc\lib\site-packages\cellacdc\gui.py", line 18235, in saveData self.computeVolumeRegionprop() File "D:\Programme\Anaconda3\envs\acdc\lib\site-packages\cellacdc\gui.py", line 17964, in computeVolumeRegionprop vol_vox, vol_fl = _calc_rot_vol( File "D:\Programme\Anaconda3\envs\acdc\lib\site-packages\cellacdc\cca_functions.py", line 524, in _calc_rot_vol obj.image.astype(np.single), -(obj.orientation180/np.pi), File "D:\Programme\Anaconda3\envs\acdc\lib\site-packages\skimage\measure_regionprops.py", line 225, in func2d raise NotImplementedError('Property %s is not implemented for ' NotImplementedError: Property orientation is not implemented for 3D images
Thanks & have a nice weekend ciao, Mario
Hi Mario,
OK this one interesting. Basically for some reason it thinks the segmentation is 2D and it tries to compute the volume from 2D but then the object is 3D and it raises that error. I will now check why it could think this and I let you know soon.
Cheers Francesco
For the combined measurement instead I never thought about deleting it, so I will add this feature you are right. For now if you want to delete it, you need to delete the file ending with custom_combine_metrics.ini
inside the Position folder and also the file from the user folder. On Windows it would be something like C:\Users\your_name\acdc-metrics\combine_metrics.ini
.
I created a new feature request in #183 for this.
Let me know if deleting those files works. Thanks!
Cheers Francesco
Hi Mario, I cannot see an obvious way for the error you had, so I think the easiest would be to test with your data. Could you please zip the Position folder and send it to me? Thanks!
Ok, I finally managed to replicate this and I fixed it. I will release soon a fix for the other errors about the second channel in cellpose. Thank you for your patience and have a good weekend!
Cheers, Francesco
Hi Mario,
I released v1.2.4rc51
with a fix for this last error. To update, please activate the acdc
environment and then install the latest version with the command pip install --upgrade cellacdc
.
Let me know if it works, thanks!
Note that this last version is also a solution for #183. You can now delete custom combined metrics from the set measurements window. Let me know in that issue if it works, thanks!
Hi Francesco,
great, thank you very much! I will try it as soon as possible.
Best Mario
Hi, this issue had no activity for more than 180 days. For now, we have marked it as "dormant" until there is some new activity. The reason is that we haven't had the time to implement this or it requires more discussion. Note that it doesn't mean it has been ignored, but a little reminder from your side would help :D. Feel free to reach out to us here or on our forum. If you think that this issue is no longer relevant, you may close it by yourself. In any case, we apologise for the inconvenience and we thank you for your patience and contributions so far!
Hi Francesco,
sorry for the additional work, but i have a new issue when trying to save metrics (until now just tried on 3D segmentation using Cellpose).
I get the following error:
Traceback (most recent call last): File "D:\Programme\Anaconda3\envs\acdc\lib\site-packages\cellacdc\myutils.py", line 49, in inner_function result = func(self, *args, *kwargs) File "D:\Programme\Anaconda3\envs\acdc\lib\site-packages\cellacdc\gui.py", line 18081, in saveData self.computeVolumeRegionprop() File "D:\Programme\Anaconda3\envs\acdc\lib\site-packages\cellacdc\gui.py", line 17810, in computeVolumeRegionprop vol_vox, vol_fl = _calc_rot_vol( File "D:\Programme\Anaconda3\envs\acdc\lib\site-packages\cellacdc\cca_functions.py", line 516, in _calc_rot_vol obj.image.astype(np.single), -(obj.orientation180/np.pi), File "D:\Programme\Anaconda3\envs\acdc\lib\site-packages\skimage\measure_regionprops.py", line 225, in func2d raise NotImplementedError('Property %s is not implemented for ' NotImplementedError: Property orientation is not implemented for 3D images
Furthermore, is it normal, that i can not access certain functions (neither using the tool bar nor within the pull down menues) as shown in the attached screen shot?
Thanks a lot best Mario