Closed andersonwinkler closed 3 years ago
PS: this works:
tmp.cdata = zeros(somesize);
gii = gifti(tmp);
The problem then is that all original meta-data are lost. Populating them by hand in the gii.private
, again, seems to work and the file is saved, but then it won't be loaded again.
Hi Anderson,
I don't manage to reproduce the error. Would you be able to share a .gii
file here or by email that triggers the error? I can think of a potential issue (when cdata has multiple columns) but it would help to see an example.
Hi Guillaume,
Thanks for the prompt reply. It is indeed a file with multiple columns (these are outputs from FMRIPREP). I've placed an example here: https://www.dropbox.com/s/3n2e5brrk3zfw01/goodfile.func.gii?dl=0. I'll send the password via email.
Thanks!
Anderson
Thanks Anderson, I got the file and could reproduce the error.
It's a kind of a long-standing issue on how to store multidimensional functional arrays in GIfTI: one MxN DataArray or N Mx1 DataArrays. I don't remember all of the details but it seems that I initially went for the first approach while the standard converged to the second approach (see this and that). There is a good chance the code nowadays tries to handle both approaches, apparently unsuccessfully.
While I find the time to look into this in more details, does the following change fixes the issue for you?
--- a/@gifti/subsasgn.m
+++ b/@gifti/subsasgn.m
@@ -127,7 +127,14 @@ switch subs(1).type
this.data{n}.attributes.Dim = size(A);
end
else
- error('Syntax not implemented.');
+ if numel(n) == size(A,2)
+ for i=n(:)'
+ this.data{i}.data = single(A(:,i));
+ this.data{i}.attributes.Dim = size(this.data{i}.data);
+ end
+ else
+ error('Syntax not implemented.');
+ end^M
end
end
end
It worked! I can now assign values to cdata, save, and the file opens just fine in other software (e.g., in FreeView).
Many thanks Guillaume! This is superb!
Cheers,
Anderson
OK, thanks for the feedback. It will need some more work and refactoring but for now I am going to push this change as the library is better with than without.
Cheers!
Hi Guillaume,
Consider this example:
I tried editing directly the
gii.private.(...)
fields, and the file then can even be saved, but then it appears to be invalid and can't be read back with gifti.Not sure what to do...
Thanks!
Cheers,
Anderson