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

No checkerboard visible in output image #3

Closed
lalet opened this issue Apr 12, 2018 · 15 comments
Closed

No checkerboard visible in output image #3

lalet opened this issue Apr 12, 2018 · 15 comments

Comments

@lalet
Copy link

lalet commented Apr 12, 2018

  • mrivis version: 0.2.8
  • Python version: 3.4
  • Operating System: CentOS7

Description

from mrivis import checkerboard
plot = checkerboard('T2w_acpc.nii.gz','T2w_acpc_centos7.nii.gz',patch_size=10)
plot.savefig("T2w_tilt.png")

These two files are output from two operating systems.   
They are completely off w.r.t alignment and we tried to visualize the differences using checkerboard. 
But no checkerboard is visible in the output image.  
Thanks for fixing the other issue, but it would be greatly appreciated if you have any hint on this one. Please find attached the output image.

t2w_tilt @glatard

@raamana
Copy link
Owner

raamana commented Apr 12, 2018

that's weird - did you try producing collages for them separately, and be sure that they are indeed off?

@raamana
Copy link
Owner

raamana commented Apr 12, 2018

e.g.

from mrivis import collage
plot1 = collage('T2w_acpc.nii.gz')
plot2 = collage('T2w_acpc_centos7.nii.gz')

@lalet
Copy link
Author

lalet commented Apr 12, 2018

Let me try that

@lalet
Copy link
Author

lalet commented Apr 12, 2018

t2w_acpc

To give you and idea, this is how it looks using fsleyes while I flicker through both files.

@raamana
Copy link
Owner

raamana commented Apr 12, 2018

I see - did you try different checker sizes, like 3 and 5 voxels etc..

Is it possible for you to share the files with me, so I can try it myself? Its perfectly fine if you can't.

@lalet
Copy link
Author

lalet commented Apr 12, 2018

Sure ! Can I have your mail id ?

@raamana
Copy link
Owner

raamana commented Apr 12, 2018

It is praamana@research.baycrest.org

@raamana
Copy link
Owner

raamana commented Apr 12, 2018

they might be too big for email - so upload to some google drive or dropbox and send a link

@lalet
Copy link
Author

lalet commented Apr 12, 2018

Thank you. I have sent a mail.

@raamana
Copy link
Owner

raamana commented Apr 12, 2018

Hi Lalet,

I can see the differences with smaller patch sizes..

try this

import os
from os.path import join as pjoin, abspath, realpath, basename, dirname, exists as pexists
from mrivis import checkerboard, color_mix, voxelwise_diff

test_dir = dirname(realpath(__file__))
base_dir = realpath(pjoin(test_dir, '..', '..', 'example_datasets'))
out_dir = realpath(pjoin(base_dir, 'centos_ver_diff'))
os.makedirs(out_dir, exist_ok=True)

c7 = pjoin(base_dir, 'T2w_acpc_centos7.nii.gz')
not_c7 = pjoin(base_dir, 'T2w_acpc.nii.gz')

im_sets = ((c7, not_c7, 'CentOS different versions'),
           )

num_rows = 1
num_cols = 3
img_lim = None 
rescaling='each'

patch_set = (1, 2, 3, 5, 8, 10, 25, 40)
for im_set in im_sets:
    for ps in patch_set:
        comb_id = 'checkerboard patch size {}'.format(ps)
        out_path = pjoin(out_dir, comb_id.replace(' ', '_'))
        checkerboard(im_set[0], im_set[1],
                     patch_size=ps,
                     rescale_method=rescaling,
                     num_rows=num_rows,
                     num_cols=num_cols,
                     annot=comb_id,
                     output_path=out_path)

Perhaps the rescale method is making a difference.. need to check.

@raamana
Copy link
Owner

raamana commented Apr 12, 2018

change the base_dir to where the images are.

@raamana
Copy link
Owner

raamana commented Apr 12, 2018

and voxelwise_diff or color_mix is probably better suited for this purpose:

num_rows = 2
num_cols = 5
img_lim = None # [0, 4000]
rescaling='each'

for im_set in im_sets:
    comb_id = 'voxelwise_diff'
    out_path = pjoin(out_dir, comb_id.replace(' ', '_'))
    voxelwise_diff(im_set[0], im_set[1],
                   rescale_method=rescaling,
                   overlay_image=True,
                   overlay_alpha=0.7,
                   background_threshold=25,
                   num_rows=num_rows,
                   num_cols=num_cols,
                   annot=comb_id,
                   output_path=out_path)

@raamana
Copy link
Owner

raamana commented Apr 12, 2018

color mix - you see the red along the borders?
color_mix_alpha_1 00

voxel wise diff
voxelwise_diff

@lalet
Copy link
Author

lalet commented Apr 12, 2018

Yes yes ! This is awesome. Thank you @raamana

@raamana raamana closed this as completed Apr 12, 2018
@raamana
Copy link
Owner

raamana commented May 31, 2018

Hi @glatard, can you take a look at this thread, and let me know your comments? I just want to make sure I fix the bug in my checkerboard implementation if it exists.

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

2 participants