Cannot open file anymore when converting Nifti to DICOM

7 次查看(过去 30 天)
I have a script where I convert MRI nifti files to DICOM. This used to work but now I get an error when trying to create a new folder and saving the converted files into that folder:
First steps work (Part I):
%% load data
% REVISIT - adapt all text between 'apostrophes'
patientID = 'patient180'; % this is the folder with the specific patient data
patientIn = fullfile('7Tseg_Brainlab', patientID); % this is the folder where the patient folders are in
patientFolder = fullfile... % this is the whole path to the patientIn folder
('here is whole path',patientIn);
addpath(genpath(patientIn));
dicom_template = '00501_3D_TSE_0.7mm'; % this is the original dicom that is used for the new dicom header
Then with this part I get an error (Part II):
% note: the [space] before the second ' after the names is necessary,
% otherwise you will get an error
cmdNiftiToDicom = ['niftitodicom.exe -o' patientFolder '\LmSTN ' patientFolder '\7T2LRmSTN.nii.gz ' patientFolder '\00501_3D_TSE_0.7mm\00001.dcm --sagittal ' '--series-description LmSTN '];
statusNiftiToDicom = system( cmdNiftiToDicom );
cmdNiftiToDicom = ['niftitodicom.exe -o' patientFolder '\RmSTN ' patientFolder '\7T2LRmSTN.nii.gz ' patientFolder '\00501_3D_TSE_0.7mm\00001.dcm --sagittal ' '--series-description RmSTN '];
statusNiftiToDicom = system( cmdNiftiToDicom);
So what I want is 2 folders, named 'LmSTN' and 'RmSTN'. This used to work and now I get the error saying 'Cannot open file', but I do use the correct path.

回答(1 个)

Karl
Karl 2024-8-5
Check whether the values of cmdNiftiToDicom correspond to commands that you can run outside of MATLAB.
Do you need a space after the -o in the character arrays used for command construction, so 'niftitodicom.exe -o ' (space at end) rather than 'niftitodicom.exe -o' (no space at end)?

类别

Help CenterFile Exchange 中查找有关 DICOM Format 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by