Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 22 additions & 21 deletions Batch_Recon/Batch_Manager_KM.m
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ function Select_Batch(val)
try
script_batch_cDTI_KM(Batch_struct.struct_diff(cpt_diff),Batch_struct.UI);
Batch_struct.struct_diff(cpt_diff).hasError=false;
catch
disp(['Problem with ' Batch_struct.struct_diff(cpt_diff).Patient ' serie ' num2str(Batch_struct.struct_diff(cpt_diff).SerieNumber)]);
catch ME
disp(['Problem with ' Batch_struct.struct_diff(cpt_diff).Patient ' serie ' num2str(Batch_struct.struct_diff(cpt_diff).SerieNumber) ':' ME.message]);
Batch_struct.struct_diff(cpt_diff).hasError=true;
end

Expand Down Expand Up @@ -189,8 +189,8 @@ function Select_Batch(val)
try
script_batch_DICOM_KM(Batch_struct.struct_diff(cpt_diff));
Batch_struct.struct_diff(cpt_diff).hasDicomError=false;
catch
disp(['Problem with DICOM Recon ' Batch_struct.struct_diff(cpt_diff).Patient ' serie ' num2str(Batch_struct.struct_diff(cpt_diff).SerieNumber)]);
catch ME
disp(['Problem with DICOM Recon ' Batch_struct.struct_diff(cpt_diff).Patient ' serie ' num2str(Batch_struct.struct_diff(cpt_diff).SerieNumber) ':' ME.message]);
Batch_struct.struct_diff(cpt_diff).hasDicomError=true;
end
Update_Batch_Table();
Expand Down Expand Up @@ -226,7 +226,7 @@ function Select_Batch(val)


Batch_struct.UI=UIDiffRecon_KM(true);


listing=dir(fullfile(Batch_struct.dcm_dir, '**'));
listing=listing(~[listing.isdir]); % Remove folder
Expand All @@ -238,20 +238,19 @@ function Select_Batch(val)

listing_dcm=[];
for cpt_folder=1:length(listing_folder)

listing_dcm=[listing_dcm; dir(listing_folder(cpt_folder))];
%
contents = dir(strtrim(listing_folder(cpt_folder)));
listing_dcm=[listing_dcm; contents];
end

[struct_diff, struct_final, ListNames, ListSeries]=Analyze_Content_local(listing_dcm,[]); % Create a brand new list_update;

Batch_struct.struct_diff=struct_diff;
Batch_struct.struct_update=struct_final;
Batch_struct.DataUI = Struct2DataUI(struct_diff);

Batch_loaded=true;
end

function Load_Batch

[file path]=uigetfile('.mat');
Expand All @@ -274,12 +273,11 @@ function Select_Batch(val)
end
function Update_Batch_Table
if Batch_loaded

if UI_created % we update the batch from the UI only if the UI already exist
Batch_struct.struct_diff=DataUI2Struct(Batch_struct.struct_diff,uit.Data);
end

for cpt_diff=1:length(Batch_struct.struct_diff)

fullfile(string(Batch_struct.dcm_dir),'Batch_Recon','Maps_'+string(Batch_struct.struct_diff(cpt_diff).Patient)+'_'+Batch_struct.struct_diff(cpt_diff).SerieNumber+'_'+string(Batch_struct.name(1:end-4)));
Batch_struct.struct_diff(cpt_diff).ReconFolder=fullfile(string(Batch_struct.dcm_dir),'Batch_Recon','Maps_'+string(Batch_struct.struct_diff(cpt_diff).Patient)+'_'+Batch_struct.struct_diff(cpt_diff).SerieNumber+'_'+string(Batch_struct.name(1:end-4)));
Batch_struct.struct_diff(cpt_diff).ReconDcmFolder=fullfile(string(Batch_struct.dcm_dir),'Dicom_Recon','Maps_'+string(Batch_struct.struct_diff(cpt_diff).Patient)+'_'+Batch_struct.struct_diff(cpt_diff).SerieNumber+'_'+string(Batch_struct.name(1:end-4)));
Expand Down Expand Up @@ -323,13 +321,13 @@ function Select_Batch(val)
LL=Batch_struct.struct_update(cpt).Listing;
folderAlreadySorted=[folderAlreadySorted string(unique(string({LL(:).folder})))];
end
folderAlreadySorted=deblank(folderAlreadySorted);
folderAlreadySorted=strtrim(folderAlreadySorted);
% Idx=contains(folderAlreadySorted , 'Dicom_Recon' );
% folderAlreadySorted(Idx)=[];

for cpt_folder=1:length(listing_folder)
if( ~contains(deblank(listing_folder(cpt_folder)) , folderAlreadySorted))
listing_dcm=[listing_dcm; dir(listing_folder(cpt_folder))];
if( ~contains(strtrim(listing_folder(cpt_folder)) , folderAlreadySorted))
listing_dcm=[listing_dcm; dir(strtrim(listing_folder(cpt_folder)))];
end
%
end
Expand Down Expand Up @@ -397,7 +395,6 @@ function Select_Batch(val)
end
function struct_diff=DataUI2Struct(struct_diff,DataUI)


for cpt_diff=1:length(struct_diff)


Expand All @@ -424,13 +421,17 @@ function Select_Batch(val)
cpt_name=0;
k=1;
h = waitbar(0,'Analyzing the folders...');
for cpt=1:1:size(listing,1)
for cpt=1:1:size(listing,1)
if ~listing(cpt).isdir & isempty(strfind(listing(cpt).folder,'Batch_Recon'))

[FolderName, name, fExt] = fileparts(listing(cpt).name);
[FolderName, name, fExt] = fileparts(listing(cpt).name);

if (strcmp(fExt, '.dcm') | strcmp(fExt, '.IMA') | isempty(fExt)) & ~ strcmp('DICOMDIR',listing(cpt).name)
tmpInfo=dicominfo(fullfile(listing(cpt).folder , listing(cpt).name));
try
tmpInfo=dicominfo(fullfile(listing(cpt).folder , listing(cpt).name));
catch dicomerr
disp(['Failed to parse DICOM information from file ' string(listing(cpt).name)])
end
%tmpDcm=dicomread([listing(cpt).folder '\' listing(cpt).name]);
%Dcm(:,:,k)=double(dicomread(listing(cpt).name));
%Dcm(k)=tmpInfo.SeriesNumber;
Expand Down Expand Up @@ -480,7 +481,7 @@ function Select_Batch(val)
badc=~isempty(strfind(tmpImageType,'ADC'));
bfa=~isempty(strfind(tmpImageType,'FA'));
bten=~isempty(strfind(tmpImageType,'TENSOR'))&isempty(strfind(tmpImageType,'TENSOR_B0'));

if ~isfield (tmpInfo,'PatientID')
if isfield (tmpInfo,'OtherPatientID')
tmpInfo.PatientID=tmpInfo.OtherPatientID;
Expand Down
2 changes: 1 addition & 1 deletion Script_Recon/script_batch_DICOM_KM.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function script_batch_DICOM_KM(struct_diff)
Recon_Local_Dicom_Maps(struct_diff,tmpMap.FA*1e3,tmpEnum,'FA',50000,[0 1e3]);
end

if isfile(fullfile(struct_diff.ReconFolder, 'HA.mat') && isfile(fullfile(struct_diff.ReconFolder, 'ROI.mat'))
if isfile(fullfile(struct_diff.ReconFolder, 'HA.mat')) && isfile(fullfile(struct_diff.ReconFolder, 'ROI.mat'))
tmpMap=load(fullfile(struct_diff.ReconFolder, 'HA.mat'));
tmpMap2=load(fullfile(struct_diff.ReconFolder, 'ROI.mat'));
Recon_Local_Dicom_Maps(struct_diff,(tmpMap.HA_filter2+90)*1e1.*tmpMap2.LV_Mask,tmpEnum,'HA',60000,[0 180*1e1]);
Expand Down