nipreps / nireports

The NiPreps' Reporting and Visualization system - report templates and "reportlets"
https://nireports.readthedocs.io
Apache License 2.0
7 stars 19 forks source link

Weird aspect ratio of some mosaic plots #53

Closed oesteban closed 1 year ago

oesteban commented 1 year ago

What happened?

https://output.circle-artifacts.com/output/job/0d458179-b043-4f5c-ae2e-25bb26f98f15/artifacts/0/tmp/t1w/derivatives/sub-51187_T1w.html

What command did you use?

mriqc

What version of fMRIPrep are you running?

n/a

How are you running this software?

Local installation ("bare-metal")

Is your data BIDS valid?

Yes

Are you reusing any previously computed results?

No

Please copy and paste any relevant log output.

No response

Additional information / screenshots

No response

celprov commented 1 year ago

I have the same problem running MRIQC v.23.0.0rc0 through Docker on the IXI dataset. All the mosaics are elongated.

image image

effigies commented 1 year ago

What are the affines of the original images?

celprov commented 1 year ago

According to,

import nibabel as nib img = nib.load("filename") img.affine

The affines are different for each image.

Could you be more precise on what information do you need?

image

img.shape = img3.shape = (256,256,150) img2.shape = img4.shape = (256,256,146)

effigies commented 1 year ago

Which of these images is shown above?

oesteban commented 1 year ago

The shape will also be necessary :)

BTW, images are rotated to the closest canonical, so please report

import nibabel as nib
img = nib.as_closest_canonical(nib.load("filename"))
img.affine, img.shape
celprov commented 1 year ago

The image above comes from sub-113. But it is the case for all subjects in the dataset as far as I checked.

With the as_closest_canonical

img.shape = (150, 256, 256)

img.affine = array([[ 4.58331546e-03, -2.94111557e-02, 1.19939470e+00, -8.33061523e+01], [-9.36585963e-01, 4.09624688e-02, 7.50960456e-03, 1.13431572e+02], [ 4.11258750e-02, 9.36142504e-01, 3.73532586e-02, -1.23132339e+02], [ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 1.00000000e+00]])

oesteban commented 1 year ago

Okay, I believe I know what's going on. Here the aspect ratios are calculated (the axial hard-coded 1.0 might be also related):

https://github.com/nipreps/nireports/blob/5c1a8b25257fff27cf35f87fa40eca11683c9786/nireports/reportlets/mosaic.py#L532-L536

However, these would be okay for a full image plotting. However, we are plotting zoomed in the brain mask. The aspect ratio should be calculated only with the bounding box, rather than the full images.

does that make sense?

celprov commented 1 year ago

Maybe but the View of the background of the anatomical image is also affected and the latter is not zoomed-in.