dke-questions > After using Matlab to change DICOM sequence name, new problem appear while running DKE
Showing 1-14 of 14 posts
Display:
Results per page:
Apr 27, 2018  12:04 PM | Xinman Liu
After using Matlab to change DICOM sequence name, new problem appear while running DKE
Hello, everyone. Sorry to post again because my problem is not solved yet.

So at first the process of running DKE stopped because my SequenceName and the console window reads: Converting input DICOM images to NIfTI... Error using spm_dicom_convert_series_description>nii_name (line 1186)
Invalid sequence name in DICOM header! Sequence name must contain 'ep'! And later I confirmed it with Matlab and it did show that my SequenceName contains no ' ep'

Then I use following lines in Matlab to change the sequence name of my DICOM data sucessfully. 

info=dicominfo('1.3.12.2.1107.5.2.32.35420.2018010410543453162206454');
info.SequenceName = '*ep_b0';
dbstop if error

filenames = dir('*.dcm');
for i = 1: size(filenames,1)
X =dicomread(filenames(i).name);
info = dicominfo(filenames(i).name);
info.SequenceName = '*ep_b0';
% fname= ['./result/',info.MediaStorageSOPInstanceUID, '.dcm'];
fname= strcat('test',num2str(i), '.dcm');
dicomwrite(X, fname ,info)
end

So after finishing changing the SequenceName, new problems appear, and it still doesn't work. The console window reads as following:
% Fri Apr 27 01:54:55 PM
studydir = 'F:\P8';
subject_list = {''};
preprocess_options.format = 'dicom';
preprocess_options.navg = 1;
preprocess_options.extra_b0 = 0;
preprocess_options.coreg_flag = 1;
preprocess_options.series_description = {'ep2d_diff_log2_iso20_free42_B1000_p2'};
fn_img_prefix = 'rdki';
bval = [0 1000 2000];
ndir = 30;
idx_1st_img = 1;
Kmin = 0;
NKmax = 3;
Kmin_final = 0;
Kmax_final = 3;
T = 50;
find_brain_mask_flag = 1;
dki_method.no_tensor = 0;
dki_method.linear_weighting = 1;
dki_method.linear_constrained = 1;
dki_method.nonlinear = 0;
dki_method.linear_violations = 0;
dki_method.robust_option = 0;
dki_method.noise_tolerance = 0.09;
dti_method.dti_flag = 0;
dti_method.dti_only = 0;
dti_method.no_tensor = 0;
dti_method.linear_weighting = 1;
dti_method.b_value = 1e+003;
dti_method.directions{1} = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30];
dti_method.robust_option = 0;
dti_method.noise_tolerance = 0.09;
fn_noise = '';
fwhm_img = [3.375 3.375 3.375];
fwhm_noise = [0 0 0];
median_filter_method = 2;
map_interpolation_method.flag = 0;
map_interpolation_method.order = 1;
map_interpolation_method.resolution = 1;
fn_gradients = 'gradient_vectors_siemens30.dat';
idx_gradients{1} = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30];
idx_gradients{2} = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30];

command line: dke DKEParameters.dat
Diffusional Kurtosis Estimator (DKE) version 2.6.0, February 2015
Start date and time: April 27, 2018 13:55:07
Diffusional Kurtosis Estimator (DKE) version 2.6.0
Converting input DICOM images to NIfTI... ***************************************************
* The AcquisitionNumber counter does not appear *
* to be changing from one volume to another. *
* Another possible explanation is that the same *
* DICOM slices are used multiple times. *
* The conversion is having to guess how slices *
* should be arranged into volumes. *
* NCH_PROGLIO_001 / 9 / 1
***************************************************
complete.
Co-registering images...
Error using spm_hist2
Wrong number of dims (1).
Error in spm_coreg>optfun (line 165)
Error in spm_coreg (line 88)
Error in spm_powell (line 27)
Error in spm_coreg (line 143)
Error in dke_preprocess_dicom>coregister (line 207)
Error in dke_preprocess_dicom (line 78)
Reading input images... Error using dke_estimate (line 165)
Input NIfTI image F:\P8\intermediate_processing\combined\rdki does not exist!
Error in dke (line 182)

Does anyone know what is going on? I'm in desperate need of some suggestions!! Thank you very much.

Best regards,
Xinman
Apr 27, 2018  12:04 PM | Emilie McKinnon - MUSC
RE: After using Matlab to change DICOM sequence name, new problem appear while running DKE
Hi Xinman,

Use the sequence names from the other (working) dicoms you have to guide you. Only the b0 image has a sequence name ep_b0, the other images have a sequence name that is structured ep_b1000_#gradient , etc 

Good luck, 
Emilie
Apr 27, 2018  01:04 PM | Kirk Feindel - University of Western Australia
RE: After using Matlab to change DICOM sequence name, new problem appear while running DKE
The most direct solution is to abandon using DKE to convert your DICOMs.  Just do it using dcm2niix and generate your own bvecs, or try using MRtrix to convert everything:  http://www.mrtrix.org/, or DSI Studio.

DKE is not commercial software and random user-end changes (like file naming) can lead to errors.  

Slow down, step back, and think carefully about your acquired data and what DKE can accept as input data.  The more you understand the fundamentals, the quicker you'll achieve results!
Apr 29, 2018  02:04 PM | Xinman Liu
RE: After using Matlab to change DICOM sequence name, new problem appear while running DKE
Hi, Emilie.
You are right, I did make a mistake. So I revise the command as following, and it did work. The previous problem has been solved.
% info=dicominfo('1.3.12.2.1107.5.2.32.35420.2018010410543453162206454');
% info.SequenceName = '*ep_b0';
dbstop if error

filenames = dir('*.dcm');
X =dicomread(filenames(1).name);
info = dicominfo(filenames(1).name);
info.SequenceName = '*ep_b0';
fname= strcat('test',num2str(1), '.dcm');
dicomwrite(X, fname ,info)
for i = 2: size(filenames,1)
X =dicomread(filenames(i).name);
info = dicominfo(filenames(i).name);
info.SequenceName = strcat('*ep_b1000#',num2str(i-1));
% fname= ['./result/',info.MediaStorageSOPInstanceUID, '.dcm'];
fname= strcat('test',num2str(i), '.dcm');
dicomwrite(X, fname ,info)
end

but then there's only one problem remaining, which is
 command line: dke DKEParameters.dat
Diffusional Kurtosis Estimator (DKE) version 2.6.0, February 2015
Start date and time: April 29, 2018 16:38:36
Diffusional Kurtosis Estimator (DKE) version 2.6.0
Converting input DICOM images to NIfTI... complete.
Co-registering images...
Error using spm_hist2
Wrong number of dims (1).

Error in spm_coreg>optfun (line 165)
Error in spm_coreg (line 88)
Error in spm_powell (line 27)
Error in spm_coreg (line 143)
Error in dke_preprocess_dicom>coregister (line 207)
Error in dke_preprocess_dicom (line 78)
Reading input images... Error using dke_estimate (line 165)
Input NIfTI image F:\P10\intermediate_processing\combined\rdki does not exist!
Error in dke (line 182)

[color=#000000]So I think this is the only problem that is left. Do you have any clues about it?[/color]
[color=#000000]Best regards,[/color]
[color=#000000]Xinman
[/color]
Apr 29, 2018  03:04 PM | Xinman Liu
RE: After using Matlab to change DICOM sequence name, new problem appear while running DKE
Hi, Kirk. 
Thank you for your suggestion and encouragement.
I used dcm2nii to generate bvec file before. But it doesn't work. And that's why I begin to doubt what's exactly wrong about my data. Then I used the data that I changed using Matlab based on bvec files, and the results are the same. So I think I have only one problem left which I stated a minute ago. But I will try your suggestion too and see how it goes. It's just that I don't have enough background knowledge of these softwares. It takes really long for me to understand what exactly that means.
Best regards,
Xinman
May 2, 2018  03:05 PM | David Lewis - Medical University of South Carolina
RE: After using Matlab to change DICOM sequence name, new problem appear while running DKE
Hi Xinman,

I believe I can help. I looked over the code from your previous email. In the test DICOM images that are written, SequenceName is either '*ep_b0' (for the first image) or '*ep_b1000#' (where = 1, 2, 3, ...).

What about images at a different b-value? In images with b=2000 (for example), SequenceName should include 'b2000' rather than 'b1000'.

Best,
Dave
May 2, 2018  03:05 PM | David Lewis - Medical University of South Carolina
RE: After using Matlab to change DICOM sequence name, new problem appear while running DKE
Hi,

Sorry, some of what I wrote didn't come out right in the forum post. I mean that the test images have SequenceName = '*ep_b0', '*ep_b1000#1', '*ep_b1000#2', '*ep_b1000#3', etc. There should be images with another b value.

Dave
May 3, 2018  01:05 PM | Xinman Liu
RE: After using Matlab to change DICOM sequence name, new problem appear while running DKE
Hi, David.
You are totally right!!! So I think I should go over all the DICOM data all over again. Thank you for your Suggestion!!!
Best regards,
Xinman
May 3, 2018  01:05 PM | David Lewis - Medical University of South Carolina
RE: After using Matlab to change DICOM sequence name, new problem appear while running DKE
Hi Xinman,

Glad that I could help!

Best,
Dave
May 3, 2018  01:05 PM | Xinman Liu
RE: After using Matlab to change DICOM sequence name, new problem appear while running DKE
Hi,
But there is one more Problem, the sequence Name of  every single DCM from the false Patient data was set to be 'js_b0', how would I know when it changes to b2000? I mean, in the previous data where DKE perfectly works, I can always use Matlab to check where B2000 Begins or where it b value Begins to change, but there are only 67 DCM in this Folder, but then there are altogether 85 DCM in the data that did not work.  I actually don't know how can I mirror it to the second one...
Best,
Xinman
May 3, 2018  09:05 PM | David Lewis - Medical University of South Carolina
RE: After using Matlab to change DICOM sequence name, new problem appear while running DKE
Hi Xinman,

I hope that I can help. If I understand correctly, there were 85 images in the data from the scanner. When you created the test images, there should also be 85 images (test1.dcm, test2.dcm, ..., test85.dcm). The code in your Apr 29 post should create one test image for every image from the scanner, so I don't know why you have 67 images in a folder.

You could create new test images from the original 85 images. You know what the b-values are for those images. Try to change the SequenceName values in the new test images to contain 'ep'. You can compare the SequenceName values in the test images to those in the original images to make sure they have the same b-values.

Or you can use other software to convert your DICOM files to NIfTI format, as Kirk recommended.

Best,
Dave
May 4, 2018  12:05 PM | Xinman Liu
RE: After using Matlab to change DICOM sequence name, new problem appear while running DKE
Hi, Dave.
I think I did not describe it clearly. So now I have data from two different volunteers. The first one is a healthy volunteer, and there is only 61 DCM (sorry, not 67, my mistake) in one Folder. And I can run DKE perfectly with this data. And then I have data from the Patient which is in the second folder. And it contains altogether 85 DCM. And the Sequence Name is wrong. And that's why I Need to use Matlab to Change the Name. As Emilie recomended above, I use the data of the healthy volunteer as reference to Change the Name like, ep_b0, ep_b1000# and ep_b2000#, and I used the following lines in Matlab.
% info=dicominfo('1.3.12.2.1107.5.2.32.35420.2018010410543453162206454');
% info.SequenceName = '*ep_b0';
dbstop if error
filenames = dir('*.dcm');
X =dicomread(filenames(1).name);
info = dicominfo(filenames(1).name);
info.SequenceName = '*ep_b0';
fname= strcat('test',num2str(1), '.dcm');
dicomwrite(X, fname ,info)
for i = 2: size(filenames,1)
X =dicomread(filenames(i).name);
info = dicominfo(filenames(i).name);
info.SequenceName = strcat('*ep_b1000#',num2str(i-1));
fname= strcat('test',num2str(i), '.dcm');
dicomwrite(X, fname ,info)
end

for  j = 43: size(filenames,1)
X =dicomread(filenames(j).name);
info = dicominfo(filenames(j).name);
info.SequenceName = strcat('*ep_b2000#',num2str(j-42));
%     fname= ['./result/',info.MediaStorageSOPInstanceUID, '.dcm']
fname= strcat('test',num2str(j), '.dcm');
dicomwrite(X, fname ,info)
end

So I did have 85 DCM where all the SequenceName are already changed. The reason why I divided the DCM in half was because in the healthy volunteer's data ''ep_b2000' starts at 31st DCM. And then I assumed that in this 85-patient data it may start at 43rdDCM. But after I run it with the changed data, it still reads in the command window,
Error in spm_coreg>optfun (line 165)
Error in spm_coreg (line 88)
Error in spm_powell (line 27)
Error in spm_coreg (line 143)
Error in dke_preprocess_dicom>coregister (line 207)
Error in dke_preprocess_dicom (line 78)
Reading input images... Error using dke_estimate (line 165)
Input NIfTI image F:\P10\intermediate_processing\combined\rdki does not exist!
Error in dke (line 182)

[color=#ff0000]So I think either my assumption is wrong that 'ep-b2000#' did not start at 43rd DCM or there may be other Problems except the SequenceName of the data. Do you have any clues about when the 'ep-b2000#' starts? By the way, I also try to Change 43rd to 31st, and it doesn't work either.[/color]

[color=#ff0000]Best,[/color]
[color=#ff0000]Xinman
[/color]
May 4, 2018  12:05 PM | Emilie McKinnon - MUSC
RE: After using Matlab to change DICOM sequence name, new problem appear while running DKE
Hi Xinman, 

Are there any images in the intermediate processing folder that should be created by DKE? 

Emilie
May 5, 2018  01:05 PM | Xinman Liu
RE: After using Matlab to change DICOM sequence name, new problem appear while running DKE
Hi, Emilie,
So I check both folders. The folder with which I can run DKE successfully contains 3 folders, named "combined", "dki_avg_coreg" and "dki_avg_nii" persepctively. And each folder contains NII files like rdki_0.nii, rdki_1000_1-30.nii and rdki_2000_1-30.nii, and in dki_avg1_nii contains one more named meandki_0.nii
While in the folder that fails to run DKE, in the intermediate_processing folder there is only one folder named "dki_avg1_nii", and then it also contains rdki_0.nii, rdki_1000_1-42.nii and rdki_2000_1-42.nii, without meandki_0.nii
Do you know what's wrong with that? Looking forward to your reply. 
Best regards,
Xinman