Skip to content

Commit bdbd77b

Browse files
committed
[bug] fix incorrect byte length in composite data types (such as RGB)
1 parent 8392b54 commit bdbd77b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

nii2jnii.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,6 @@
208208
return
209209
end
210210

211-
if (type2str{typeidx, 2} > 1)
212-
nii.hdr.dim = [nii.hdr.dim(1) + 1 uint16(nii.datalen) nii.hdr.dim(2:end)];
213-
end
214-
215211
if (nargin > 1 && strcmp(format, 'niiheader'))
216212
return
217213
end
@@ -222,6 +218,10 @@
222218

223219
imgbytenum = prod(double(nii.hdr.dim(2:nii.hdr.dim(1) + 1))) * nii.voxelbyte;
224220

221+
if (type2str{typeidx, 2} > 1)
222+
nii.hdr.dim = [nii.hdr.dim(1) + 1 uint16(nii.datalen) nii.hdr.dim(2:end)];
223+
end
224+
225225
if (isnii == 0 && ~isempty(regexp(filename, '\.[Gg][Zz]$', 'once')))
226226
finput = fopen(filename, 'rb');
227227
input = fread(finput, inf, 'uint8=>uint8');

0 commit comments

Comments
 (0)