Skip to content

Commit

Permalink
major bugs for long recordings in QRS_detection_post_process task
Browse files Browse the repository at this point in the history
  • Loading branch information
marianux committed Aug 11, 2015
1 parent 60a9bac commit df838a4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
25 changes: 14 additions & 11 deletions common/ECGtask_ECG_delineation.m
Original file line number Diff line number Diff line change
Expand Up @@ -180,30 +180,33 @@ function Start(obj, ECG_header, ECG_annotations)

fnames = fieldnames(obj.payload);
aux_idx = find(cell2mat( cellfun(@(a)(~isempty(strfind(a, 'corrected_'))), fnames, 'UniformOutput', false)));

aux_struct = obj.payload;

if( isempty(aux_idx) )

if( isfield(obj.payload, 'series_quality') )
[~, aux_idx] = sort(obj.payload.series_quality.ratios, 'descend');
aux_val = obj.payload.(obj.payload.series_quality.AnnNames{aux_idx(1),1}).(obj.payload.series_quality.AnnNames{aux_idx(1),2}) - ECG_start_offset + 1;
if( isfield(aux_struct, 'series_quality') )
[~, aux_idx] = sort(aux_struct.series_quality.ratios, 'descend');
aux_val = aux_struct.(aux_struct.series_quality.AnnNames{aux_idx(1),1}).(aux_struct.series_quality.AnnNames{aux_idx(1),2}) - ECG_start_offset + 1;
aux_val = aux_val( aux_val >= ECG_sample_start_end_idx(1) & aux_val < ECG_sample_start_end_idx(2) );
obj.payload = aux_val;
aux_struct = aux_val;

else
for fname = rowvec(fnames)
if( isfield(obj.payload.(fname{1}), 'time') )
aux_val = obj.payload.(fname{1}).time - ECG_start_offset + 1;
if( isfield(aux_struct.(fname{1}), 'time') )
aux_val = aux_struct.(fname{1}).time - ECG_start_offset + 1;
aux_val = aux_val( aux_val >= ECG_sample_start_end_idx(1) & aux_val < ECG_sample_start_end_idx(2) );
obj.payload = aux_val;
aux_struct = aux_val;
break
end
end
end
else

for ii = rowvec(aux_idx)
aux_val = obj.payload.(fnames{ii}).time - ECG_start_offset + 1;
aux_val = aux_struct.(fnames{ii}).time - ECG_start_offset + 1;
aux_val = aux_val( aux_val >= ECG_sample_start_end_idx(1) & aux_val < ECG_sample_start_end_idx(2) );
obj.payload = aux_val;
aux_struct = aux_val;
end
end

Expand Down Expand Up @@ -235,7 +238,7 @@ function Start(obj, ECG_header, ECG_annotations)

try

[position_multilead, positions_single_lead] = wavedet_interface(ECG, ECG_header, obj.payload, obj.lead_idx, obj.wavedet_config, ECG_sample_start_end_idx, ECG_start_offset, obj.progress_handle);
[position_multilead, positions_single_lead] = wavedet_interface(ECG, ECG_header, aux_struct, obj.lead_idx, obj.wavedet_config, ECG_sample_start_end_idx, ECG_start_offset, obj.progress_handle);

for jj = 1:length(obj.lead_idx)
payload_out.wavedet.(obj.lead_names{obj.lead_idx(jj)}) = positions_single_lead(jj);
Expand Down Expand Up @@ -269,7 +272,7 @@ function Start(obj, ECG_header, ECG_annotations)

ECG_header_aux = trim_ECG_header(ECG_header, obj.lead_idx);

[positions_single_lead, position_multilead] = ud_func_pointer( double(ECG(:,obj.lead_idx)), ECG_header_aux, obj.progress_handle, obj.payload);
[positions_single_lead, position_multilead] = ud_func_pointer( double(ECG(:,obj.lead_idx)), ECG_header_aux, obj.progress_handle, aux_struct);

% filter and offset delineation
for jj = 1:length(obj.lead_idx)
Expand Down
7 changes: 5 additions & 2 deletions common/ECGtask_QRS_detections_post_process.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,16 @@ function Start(obj, ECG_header, ECG_annotations)
if( isstruct(obj.payload) )

AnnNames = obj.payload.series_quality.AnnNames(:,1);
aux_struct = obj.payload;

for fn = rowvec(AnnNames)
aux_val = obj.payload.(fn{1}).time - ECG_start_offset + 1;
aux_val = aux_val( aux_val >= ECG_sample_start_end_idx(1) & aux_val < ECG_sample_start_end_idx(2) );
obj.payload.(fn{1}).time = aux_val;
aux_struct.(fn{1}).time = aux_val;
end

else
return
end

for this_func = rowvec(obj.post_proc_func)
Expand All @@ -130,7 +133,7 @@ function Start(obj, ECG_header, ECG_annotations)
% this_func_ptr = eval(['@' this_func]);
this_func_ptr = str2func(this_func{1});

this_payload = this_func_ptr( obj.payload, ECG_header, ECG_sample_start_end_idx );
this_payload = this_func_ptr( aux_struct, ECG_header, ECG_sample_start_end_idx );

for fn = rowvec(fieldnames(this_payload))
payload_out.(fn{1}) = this_payload.(fn{1});
Expand Down
2 changes: 1 addition & 1 deletion common/ECGwrapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
% maximum debugging email report file size
max_report_filesize = 4 * 1024^2; % bytes
% Maximum time to wait for other PIDs finishing their work.
Time2WaitPIDs = 2 * 60; % seconds.
Time2WaitPIDs = 0 * 60; % seconds.

end

Expand Down

0 comments on commit df838a4

Please sign in to comment.