Dear Guangyu I have tried your script. But it showed some errors. I think it may be some filename issues. Error: failed to open file /AD_002_S_5018_201211_05_rm10_tshift_despike_volreg_masked_Qwarped_smooth6_detrend_rmnoise_bandpass.nii_Vols_1.nii.gz Image Exception : #22 :: ERROR: Could not open image /AD_002_S_5018_201211_05_rm10_tshift_despike_volreg_masked_Qwarped_smooth6_detrend_rmnoise_bandpass.nii_Vols_1 Error: failed to open file /AD_002_S_5018_201211_05_rm10_tshift_despike_volreg_masked_Qwarped_smooth6_detrend_rmnoise_bandpass.nii_Vols_2.nii.gz Image Exception : #22 :: ERROR: Could not open image /AD_002_S_5018_201211_05_rm10_tshift_despike_volreg_masked_Qwarped_smooth6_detrend_rmnoise_bandpass.nii_Vols_2 Error: failed to open file /AD_002_S_5018_201211_05_rm10_tshift_despike_volreg_masked_Qwarped_smooth6_detrend_rmnoise_bandpass.nii_Vols_1.nii Image Exception : #22 :: ERROR: Could not open image /AD_002_S_5018_201211_05_rm10_tshift_despike_volreg_masked_Qwarped_smooth6_detrend_rmnoise_bandpass.nii_Vols_1 terminate called after throwing an instance of 'RBD_COMMON::BaseException' Aborted (core dumped) Error: failed to open file /AD_002_S_5018_201211_05_rm10_tshift_despike_volreg_masked_Qwarped_smooth6_detrend_rmnoise_bandpass.nii_Vols_2.nii Image Exception : #22 :: ERROR: Could not open image /AD_002_S_5018_201211_05_rm10_tshift_despike_volreg_masked_Qwarped_smooth6_detrend_rmnoise_bandpass.nii_Vols_2 terminate called after throwing an instance of 'RBD_COMMON::BaseException' Aborted (core dumped) Best Zhen > 在 2018年11月15日,16:39,Guangyu Zhou <[log in to unmask]> 写道: > > Dear Zhen, > > Your task could be done easily with fslroi, see below > fslroi input-image.nii Vols_1-90.nii 0 90 > fslroi input-image.nii Vols_46-135.nii 45 90 > > If you have a bunch of such 4d nii files in one folder, some shell script might be helpful. > > cd to-your-folder > save_path=directory-to-save-results > for vol in $( ls *.nii) > do > volname=$( basename ${vol}) > fslroi ${vol} ${save_path}/${volname}_Vols_1-90 0 90 > fslroi ${vol} ${save_path}/${volname}_Vols_46-135 45 90 > > # comment the lines below if .nii.gz files work for you > fslchfiletype NIFTI ${save_path}/${volname}_Vols_1-90 ${save_path}/${volname}_Vols_1-90 > fslchfiletype NIFTI ${save_path}/${volname}_Vols_46-135 ${save_path}/${volname}_Vols_46-135 > done > > > Hope this helps. > > Best, > > Guangyu > > > On Thu, Nov 15, 2018 at 3:16 PM Zhen Zhou <[log in to unmask] <mailto:[log in to unmask]>> wrote: > Dear FSL experts > > I have thousands of nii files. Let’s see they all have 145 volumes. And I want to split the 4D file into 2 4D files for each nii file. The first 4D nii file has the first 90 volumes and the second file has the 46-135 volume. They have a overlap of 45 volumes. So how could I do this ? > > Best > Zhen > ######################################################################## > > To unsubscribe from the FSL list, click the following link: > https://www.jiscmail.ac.uk/cgi-bin/webadmin?SUBED1=FSL&A=1 <https://www.jiscmail.ac.uk/cgi-bin/webadmin?SUBED1=FSL&A=1> > > To unsubscribe from the FSL list, click the following link: > https://www.jiscmail.ac.uk/cgi-bin/webadmin?SUBED1=FSL&A=1 <https://www.jiscmail.ac.uk/cgi-bin/webadmin?SUBED1=FSL&A=1> ######################################################################## To unsubscribe from the FSL list, click the following link: https://www.jiscmail.ac.uk/cgi-bin/webadmin?SUBED1=FSL&A=1