mrirecon / bart

BART: Toolbox for Computational Magnetic Resonance Imaging
https://mrirecon.github.io/bart/
BSD 3-Clause "New" or "Revised" License
301 stars 164 forks source link

bart copy does not behave like expected #341

Closed dabosch closed 1 day ago

dabosch commented 1 month ago

Hi,

the help of bart copy (bart copy -h) tells me what it supposedly does:

Copy an array (to a given position in the output file - which then must exist).

From this I assume that data from array a is copied into a position of array b, overwriting what's already in those positions, and implicitely not modifying the rest of array b. However, when I use it, array b is actually completely cleared, and only the data from array b is still there. So either the description is unclear, or the behavior is not as intended.

I added a demo below.

Best, Dario

Demo:

# generate a phantom
bart phantom -x128 phantom
bart toimg phantom phantom.png

phantom

#now extract the 2nd half of the phantom and scale it with factor 1.2 (make it a bit brighter)
bart extract 1 64 128 phantom phantom_right
bart scale 1.2 phantom_right phantom_right
bart toimg phantom_right phantom_right.png

phantom_right

# copy the scaled portion back into a copy of the original array
cp phantom.cfl phantom_copied.cfl
cp phantom.hdr phantom_copied.hdr
bart copy 1 64 phantom_right phantom_copied
bart toimg phantom_copied phantom_copied.png

phantom_new

I would expect the image to be a complete phantom, with the right half to be a bit brighter than the left half. Instead, the left half is completely lost. For the intended result, I have to also extract the other portion of the data and stitch it together:

# join left and right half
bart extract 1 0 64 phantom phantom_left
bart toimg phantom_left phantom_left.png
bart join 1 phantom_left phantom_right phantom_joined  
bart toimg phantom_joined phantom_joined.png

phantom_joined

mblum94 commented 1 day ago

Thank you for reporting this bug. We fixed it and will commit the update soon.