Converting DICOM files to Analyze file in batch mode

23 sec read

I use SPM’s dicom import function to convert DICOM files to Analyze files. But it’s quite inconvenient if I have 20 subjects. Below is a script to do this conversion automatically. You can call this function inside a loop.

function dicom2img(files)
% function dicom2img(files)
%
% This function is to convert dicom files to Analyze image files using SPM
% script
%
% files (optional): list of dicom files
%
% Xu Cui
%

if(nargin < 1)
    if findstr('SPM2',spm('ver'))
        files = spm_get('files', pwd, '*.dcm');
    else
        files = spm_select('list', pwd, '\.dcm');
    end
end

spm_defaults; 
hdr = spm_dicom_headers(files);
spm_dicom_convert(hdr);
display('done!')
return;



写作助手,把中式英语变成专业英文


Want to receive new post notification? 有新文章通知我

第五十八期fNIRS Journal Club通知2024/12/07, 10am 王硕教授团队

理解噪音中的言语对老年听力损失患者来说是一个重大挑战。来自首都医科大学附属北京同仁医院耳鼻咽喉科研究所王硕教授团队的助理研究员王松建将为大家介绍他们采用同步EEG-fNIRS技术,从神经与血流动力学两
Wanling Zhu
10 sec read

第五十七期fNIRS Journal Club视频 王欣悦博士

Youtube: https://youtu.be/vyo-kECC2Ps 优酷:https://v.youku.com/v_show/id_XNjQzNTA0ODIwMA==.html 肢体语言——
Wanling Zhu
20 sec read

第五十七期fNIRS Journal Club通知2024/11/02, 10am 王欣悦博士

肢体语言——例如人际距离、眼神、手势等,如何影响我们的交流,是一个有趣的谜题。它们是优雅而神秘的代码,无本可依、无人知晓,却又无人不懂。来自南京师范大学的王欣悦博士将分享如何通过fNIRS超扫描技术,
Wanling Zhu
16 sec read

8 Replies to “Converting DICOM files to Analyze file in batch mode”

  1. Thanks for the code.I am using SPM5 and it does not have the function name spm_get.But I have replaced the function spm_get with spm_get_data.I have also passed the value of variable ‘files’.But still I am not getting the result.To access the files I have used following code:

    owd=input(‘Enter the path of RAW images:\n’);
    dirdata=dir(owd);
    dirIndex=[dirdata.isdir];
    files={dirdata(~dirIndex).name}’

    Kindly provide me the code and help
    Thanks

  2. The program runs and gives me error “Cant yet convert Phillips Intera DICOM”..This error is generated from spm_dicom_convert.m file.I do not understand why I am getting this message and how to remove it.

  3. The above code worked with some changes.Now in my code i need to direct the analysis files to another directory.I need it to be done inside the code.Please help me with it.
    Thanks

  4. Dear Xu!

    I am using spm8 and trying to batch the dicom import.
    Do you know how I can search also the subdirectories of the DICOM folder?

    So far,I cd to the DICOM folder and use
    [files,dirs]=cfg_getfile(‘list’, pwd, ‘.’);
    and get the subdirectories only.

    Thank you! Dorothea

Leave a Reply

Your email address will not be published. Required fields are marked *