(3drefit) nifti_image_write_engine cannot open output file

AFNI version info (afni -ver): Version AFNI_24.1.00

I'm using 3drefit -slice_timing to set slice-timing offsets. The below code has worked for all of my data, except for this one file:

 3drefit -Tslices `cat ../scripts/slice_timings_ms.txt` WIP_REST_20240510125423_401.nii.gz
++ 3drefit: AFNI version=AFNI_24.1.00 (Apr  2 2024) [64-bit]
++ Authored by: RW Cox
++ Processing AFNI dataset WIP_REST_20240510125423_401.nii.gz
 + setting slice time offsets
 + loading and re-writing dataset WIP_REST_20240510125423_401.nii.gz (/project2/skeedy/FC/FC_245/WIP_REST_20240510125423_401.nii.gz in NIFTI storage)
** ERROR (nifti_image_write_engine): cannot open output file './WIP_REST_20240510125423_401.nii.gz'
++ 3drefit processed 1 datasets

After this, 3dinfo -slice_timing still gives all 0s for the slice-timing offsets meaning it did not work.

Here's the 3dinfo for the file:

3dinfo WIP_REST_20240510125423_401.nii.gz
++ 3dinfo: AFNI version=AFNI_24.1.00 (Apr  2 2024) [64-bit]

Dataset File:    /project2/skeedy/FC/FC_245/WIP_REST_20240510125423_401.nii.gz
Identifier Code: AFN_cuMl6yePs2lSV4XfGkHuMQ  Creation Date: Wed Jul 10 07:42:09 2024
Template Space:  ORIG
Dataset Type:    Echo Planar (-epan)
Byte Order:      LSB_FIRST {assumed} [this CPU native = LSB_FIRST]
Storage Mode:    NIFTI
Storage Space:   663,552,000 (664 million) bytes
Geometry String: "MATRIX(2.21875,0,0,-108.3966,0,-2.21875,0,89.15815,0,0,2.400002,-43.64571):96,96,60"
Data Axes Tilt:  Plumb
Data Axes Orientation:
  first  (x) = Right-to-Left
  second (y) = Posterior-to-Anterior
  third  (z) = Inferior-to-Superior   [-orient RPI]
R-to-L extent:  -108.397 [R] -to-   102.385 [L] -step-     2.219 mm [ 96 voxels]
A-to-P extent:  -121.623 [A] -to-    89.158 [P] -step-     2.219 mm [ 96 voxels]
I-to-S extent:   -43.646 [I] -to-    97.954 [S] -step-     2.400 mm [ 60 voxels]
Number of time steps = 600  Time step = 0.80000s  Origin = 0.00000s
  -- At sub-brick #0 '?' datum type is short [*11.5502]
  -- At sub-brick #1 '?' datum type is short [*11.5502]
  -- At sub-brick #2 '?' datum type is short [*11.5502]
** For info on all 600 sub-bricks, use '3dinfo -verb' **

I appreciate the help!

Hmm, what are the permissions on the file?

ls -l WIP_REST_20240510125423_401.nii.gz

--pt

The permissions for this file are the same as all of the others that the command worked on:
-rw-rwxr--+ 1

Hm, OK.

Maybe if we could see the full NIFTI header that would point something out:

nifti_tool -disp_hdr -infiles WIP_REST_20240510125423_401.nii.gz

It might be helpful to see the NIFTI header of one other file where the 3drefit is successful, too.

Also, if you 3dcopy it first, does that help?

3dcopy \
  WIP_REST_20240510125423_401.nii.gz \
  WIP_REST_20240510125423_401_new.nii.gz

3drefit \
   -Tslices `cat ../scripts/slice_timings_ms.txt` \
    WIP_REST_20240510125423_401_new.nii.gz

?

(As you can tell, I don't have a deep idea about what is happening here, and Rick is on vacation for a bit, otherwise he would probably have a much better idea.)

--pt

Solved:
Well it ended up being as simple as 3dcopying it...glad it was that simple and thank you. I've included the rest of the info you asked for just it helps anyone else down the line.

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

For sure (and results of nifti_tool -diff_hdr are at the bottom)

Here's for the file that fails:

nifti_tool -disp_hdr -infiles WIP_REST_20240510125423_401.nii.gz

N-1 header file 'WIP_REST_20240510125423_401.nii.gz', num_fields = 43

all fields:
  name                offset  nvals  values
  ------------------- ------  -----  ------
  sizeof_hdr             0      1    348
  data_type              4     10
  db_name               14     18
  extents               32      1    0
  session_error         36      1    0
  regular               38      1    r
  dim_info              39      1    57
  dim                   40      8    4 96 96 60 600 1 1 1
  intent_p1             56      1    0.0
  intent_p2             60      1    0.0
  intent_p3             64      1    0.0
  intent_code           68      1    0
  datatype              70      1    4
  bitpix                72      1    16
  slice_start           74      1    0
  pixdim                76      8    -1.0 2.21875 2.21875 2.4 0.8 0.0 0.0 0.0
  vox_offset           108      1    352.0
  scl_slope            112      1    11.550239
  scl_inter            116      1    0.0
  slice_end            120      1    0
  slice_code           122      1    0
  xyzt_units           123      1    10
  cal_max              124      1    0.0
  cal_min              128      1    0.0
  slice_duration       132      1    0.0
  toffset              136      1    0.0
  glmax                140      1    0
  glmin                144      1    0
  descrip              148     80    TE=30;Time=134915.530
  aux_file             228     24
  qform_code           252      1    1
  sform_code           254      1    1
  quatern_b            256      1    0.0
  quatern_c            260      1    1.0
  quatern_d            264      1    0.0
  qoffset_x            268      1    108.396637
  qoffset_y            272      1    -89.15815
  qoffset_z            276      1    -43.64571
  srow_x               280      4    -2.21875 0.0 -0.0 108.396637
  srow_y               296      4    -0.0 2.21875 -0.0 -89.15815
  srow_z               312      4    0.0 0.0 2.400002 -43.64571
  intent_name          328     16
  magic                344      4    n+1

And here's one that was successful (before 3drefit):

N-1 header file 'REST_20231211124840_601.nii.gz', num_fields = 43

all fields:
  name                offset  nvals  values
  ------------------- ------  -----  ------
  sizeof_hdr             0      1    348
  data_type              4     10
  db_name               14     18
  extents               32      1    0
  session_error         36      1    0
  regular               38      1    r
  dim_info              39      1    57
  dim                   40      8    4 96 96 60 600 1 1 1
  intent_p1             56      1    0.0
  intent_p2             60      1    0.0
  intent_p3             64      1    0.0
  intent_code           68      1    0
  datatype              70      1    4
  bitpix                72      1    16
  slice_start           74      1    0
  pixdim                76      8    -1.0 2.21875 2.21875 2.4 0.8 0.0 0.0 0.0
  vox_offset           108      1    352.0
  scl_slope            112      1    12.894199
  scl_inter            116      1    0.0
  slice_end            120      1    0
  slice_code           122      1    0
  xyzt_units           123      1    10
  cal_max              124      1    0.0
  cal_min              128      1    0.0
  slice_duration       132      1    0.0
  toffset              136      1    0.0
  glmax                140      1    0
  glmin                144      1    0
  descrip              148     80    TE=30;Time=134803.240
  aux_file             228     24
  qform_code           252      1    1
  sform_code           254      1    1
  quatern_b            256      1    0.0
  quatern_c            260      1    1.0
  quatern_d            264      1    0.0
  qoffset_x            268      1    108.396637
  qoffset_y            272      1    -105.390617
  qoffset_z            276      1    -68.295006
  srow_x               280      4    -2.21875 0.0 -0.0 108.396637
  srow_y               296      4    -0.0 2.21875 -0.0 -105.390617
  srow_z               312      4    0.0 0.0 2.399994 -68.295006
  intent_name          328     16
  magic                344      4    n+1


Differences between headers:

nifti_tool -diff_hdr -infiles REST_20231211124840_601.nii.gz ../../FC_245/WIP_REST_20240510125423_401.nii.gz
  name                offset  nvals  values
  ------------------- ------  -----  ------
  scl_slope            112      1    12.894199
  scl_slope            112      1    11.550239
  descrip              148     80    TE=30;Time=134803.240
  descrip              148     80    TE=30;Time=134915.530
  qoffset_y            272      1    -105.390617
  qoffset_y            272      1    -89.15815
  qoffset_z            276      1    -68.295006
  qoffset_z            276      1    -43.64571
  srow_y               296      4    -0.0 2.21875 -0.0 -105.390617
  srow_y               296      4    -0.0 2.21875 -0.0 -89.15815
  srow_z               312      4    0.0 0.0 2.399994 -68.295006
  srow_z               312      4    0.0 0.0 2.400002 -43.64571


OK, I don't have a deep explanation for why that would make a difference, but I'm glad that helped sort it.

Thanks for still posting the header info, as well as the comparisons. I dont' see a meaningful difference between those (just slightly different obliquity angles, and then a different text comment about "Time=" in the descrip).

--pt