Convert from FSL format

411 views
Skip to first unread message

paula...@gmail.com

unread,
Feb 24, 2015, 7:09:33 AM2/24/15
to dsi-s...@googlegroups.com

Dear all,

We are trying to convert the output files  from BedpostX (FSL) to DSI studio format using the following code below but we got this error message: ???subscripted assignment dimension  mismatch. Error in ==>FSL_to_DSI at 16
fib.dir0(1,:,:,:) = sin(theta1.img).*cos(phi1.img);

Does anyone know how to solve this?

Thanks!

Best,
Paula


 
% You may need to download a nifti file loader to run this function.
% This example shows converting a maximum of 2 fiber populations. 
% For populations more than 2, you may need to modify the codes.

theta1 = load_untouch_nii('mean_th1samples.nii.gz');
theta2 = load_untouch_nii('mean_th2samples.nii.gz');
phi1 = load_untouch_nii('mean_ph1samples.nii.gz');
phi2 = load_untouch_nii('mean_ph2samples.nii.gz');
f1 = load_untouch_nii('mean_f1samples.nii.gz');
f2 = load_untouch_nii('mean_f2samples.nii.gz');
fib.dimension = size(f1.img);
fib.voxel_size = f1.hdr.dime.pixdim(2:4);
fib.fa0 = double(reshape(f1.img,1,[]));
fib.fa1 = double(reshape(f2.img,1,[]));
fib.dir0(1,:,:,:) = sin(theta1.img).*cos(phi1.img);
fib.dir0(2,:,:,:) = sin(theta1.img).*sin(phi1.img);
fib.dir0(3,:,:,:) = cos(theta1.img);
fib.dir1(1,:,:,:) = sin(theta2.img).*cos(phi2.img);
fib.dir1(2,:,:,:) = sin(theta2.img).*sin(phi2.img);
fib.dir1(3,:,:,:) = cos(theta2.img);
fib.dir0 = double(reshape(fib.dir0,3,[]));
fib.dir1 = double(reshape(fib.dir1,3,[]));

% flip xy: you may need to make sure that this orientation is correct

fib.fa0 = reshape(fib.fa0,fib.dimension);
fib.fa0 = fib.fa0(fib.dimension(1):-1:1,fib.dimension(2):-1:1,:);
fib.fa0 = reshape(fib.fa0,1,[]);

fib.fa1 = reshape(fib.fa1,fib.dimension);
fib.fa1 = fib.fa1(fib.dimension(1):-1:1,fib.dimension(2):-1:1,:);
fib.fa1 = reshape(fib.fa1,1,[]);


fib.dir0 = reshape(fib.dir0,[3 fib.dimension]);
fib.dir0 = fib.dir0(:,fib.dimension(1):-1:1,fib.dimension(2):-1:1,:);
fib.dir0(3,:,:,:) = -fib.dir0(3,:,:,:);
fib.dir0 = reshape(fib.dir0,3,[]);

fib.dir1 = reshape(fib.dir1,[3 fib.dimension]);
fib.dir1 = fib.dir1(:,fib.dimension(1):-1:1,fib.dimension(2):-1:1,:);
fib.dir1(3,:,:,:) = -fib.dir1(3,:,:,:);
fib.dir1 = reshape(fib.dir1,3,[]);

save('out.fib', '-struct','fib','-v4');

Fang-Cheng Yeh

unread,
Feb 25, 2015, 11:15:27 AM2/25/15
to dsi-s...@googlegroups.com
Hi Paula,

Can you check out the "size" of theta1.img and phi1.img ?

e.g. what is the output of size(theta1.img) ? and size(phi1.img)?

Best regards,
Frank
> --
> You received this message because you are subscribed to the Google Groups
> "DSI Studio" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to dsi-studio+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages