Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

soma object has no attribute 'pad' #15

Open
argunsah opened this issue Nov 25, 2019 · 7 comments
Open

soma object has no attribute 'pad' #15

argunsah opened this issue Nov 25, 2019 · 7 comments

Comments

@argunsah
Copy link

Hello,
I am tracing a neuron with a clear soma but I get this :

python ./apps/rtrace -f testlila4.tif -t 25 -z 0.5 --soma --save-soma

The shape of the image is (926, 742, 212)
-- Zooming image to 0.50 of original size
(1) -- Detecting Soma...Reconstructing Soma with Simple Mask
(2) --Boundary DT...
(3) --Fast Marching with low quality...
(4) --Compute Gradients...
(5) --Start Backtracking with standard stopping criteria ...
36888.0it [15:03, 24.15it/s] Traceback (most recent call last):
File "./apps/rtrace", line 147, in
soma.pad(crop_region)
AttributeError: 'Soma' object has no attribute 'pad'
36888.0it [15:08, 40.61it/s]

Also when I try to use --view option I get this:

The shape of the image is (926, 742, 212)
-- Zooming image to 0.50 of original size
(1) -- Detecting Soma...Reconstructing Soma with Simple Mask
(2) --Boundary DT...
(3) --Fast Marching with low quality...
(4) --Compute Gradients...
(5) --Start Backtracking with standard stopping criteria ...
26445.0it [09:24, 21.93it/s] -- Finshed: 687.66 sec.
Traceback (most recent call last):
File "./apps/rtrace", line 173, in
s.view()
File "c:\users\argunsah-adm\documents\github\rivuletpy\rivuletpy\swc.py", line 221, in view
viewer.render(return_rgb_array=False)
File "c:\users\argunsah-adm\documents\github\rivuletpy\rivuletpy\utils\rendering3.py", line 177, in render
self.transform.enable()
File "c:\users\argunsah-adm\documents\github\rivuletpy\rivuletpy\utils\rendering3.py", line 96, in enable
glPushMatrix()
File "C:\ProgramData\Anaconda3\lib\site-packages\pyglet-2.0.dev0-py3.7.egg\pyglet\gl\lib.py", line 105, in errcheck
raise GLException(msg)
pyglet.gl.lib.GLException: b'invalid operation'

Do you have any recommendation about how to solve these issues?

Thanks,

Ali

@donghaozhang
Copy link
Collaborator

Can you try to lower your threshold?

@argunsah
Copy link
Author

It didn't help. I just get more unrelated branches but the soma pad error remains.

@lsqshr
Copy link
Collaborator

lsqshr commented Nov 25, 2019

@argunsah
Hi, thanks for your interests and reporting this issue. I can confirm the issue and I am looking into it.

I have fixed it by adding the pad and save functions back to the Soma class. Before I commit the updates, do you mind sharing the testing tif?

@RivuletStudio RivuletStudio deleted a comment from donghaozhang Nov 25, 2019
@lsqshr
Copy link
Collaborator

lsqshr commented Nov 25, 2019

also the --soma flag has been deprecated (I just updated the readme). Now if you add --quality the tracing function will use the SRET algorithm to reconstruct the soma contour. Otherwise, a simple sphere estimation algorithm will be used.

@lsqshr
Copy link
Collaborator

lsqshr commented Nov 25, 2019

The second issue is caused by the pyglet package we used for the simple rendering function. I currently cannot reproduce this on my side, I guess it was caused by some package version incompatability (rejuvyesh/gym-dmcontrol#1). pyglet is known to be tricky to setup for windows.

I would recommend to drag the result swc file to a software like Vaa3D to render it for now to bypass this problem.

Pls let us know how it goes!

@argunsah
Copy link
Author

I tried with --quality option and tried visualizing the .swc using Vaa3D or HBP viewer but didn't see soma. Is this expected?

Another question, if I want to use anisotropic diffusion, what is the option for that? It is not specified in the usage help file.

@lsqshr
Copy link
Collaborator

lsqshr commented Nov 27, 2019

If you have --save-soma and --quality, the reconstructed soma mask is saved to *.tif.r2.soma.tif in the same folder as your input tif if reconstructed correctly.

For image filtering, there is a script I once implemented under apps/anifilter that supports the OOF filter and the bi-gaussian filter. It allows the soma to be masked when the image is being filtered.

I have not used this script since we started to use CNNs to preprocess the image and run rivuletpy on the CNN predicted heatmaps. So adventures expected.

$ python anifilter -h
usage: anifilter [-h] -f FILE [-o OUT] [--soma] [--no-soma] [-t THRESHOLD]
                 [--filtertype FILTERTYPE] [--rlow RLOW] [--rhigh RHIGH]
                 [--rstep RSTEP] [--rho RHO]

Arguments to perform the anisotropic filter on the input image.

optional arguments:
  -h, --help            show this help message and exit
  -f FILE, --file FILE  The input file. A image file (*.tif, *.nii, *.mat).
  -o OUT, --out OUT     The name of the output file
  --soma
  --no-soma
  -t THRESHOLD, --threshold THRESHOLD
                        The thresohld to get the segmentation for soma
                        detection. If not provided, the threshold will be
                        decided via otsu thresholding (not reliable for noisy
                        images).
  --filtertype FILTERTYPE
                        The type of filter to use for filtering images (bg or
                        oof); bf for Bi-Gaussian filter, oof for Optimal
                        Oriented Flux filter. default: oof
  --rlow RLOW           The lower bound of radius to try
  --rhigh RHIGH         The higher bound of radius to try
  --rstep RSTEP         The step size of trying radius
  --rho RHO             The rho value for the BG filter. Only used if filter
                        type is bg

For iterative anisotropic diffusion filter, there is an equavalent plugin in Vaa3D that could be called from commandline Vaa3D Menu->Plug-in->image filters-> anisotropic filter (not sure if the windows build works)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants