Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating process integration #145

Merged
merged 1 commit into from
May 23, 2024
Merged
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
2 changes: 1 addition & 1 deletion cfs_properties/process_import_channel.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "description":"", "channel_type":{ "description":"Select the type of import channel process to be used. <<raw>> Use raw data. <<default>> Use BST default template ", "type":"default", "type_list":[ { "id":"raw", "name":"raw_data", "description":"", "subID_prefix":"", "base_path":"/mnt/Store/Data/Conectome/Sample", "file_location":"meg/SubID/unprocessed/MEG/5-Restin/4D/c,rfDC", "data_format":"4D", "group_layout_name":"", "channel_layout_name":""},{ "id":"default", "name":"import_channel", "description":"Select the group and name of the sensor layout. See bst_defaults/bst_eeg_layouts.json file and select all params from there", "group_layout_name":"ICBM152", "channel_layout_name":"ASA 10-05 343"}]}, "channel_label_file":""}
{ "description":"", "channel_type":{ "description":"Select the type of import channel process to be used. <<raw>> Use raw data. <<default>> Use BST default template ", "type":"default", "type_list":[ { "id":"raw", "name":"raw_data", "description":"", "subID_prefix":"", "base_path":"/mnt/Store/Data/Conectome/Sample", "file_location":"meg/SubID/unprocessed/MEG/5-Restin/4D/c,rfDC", "data_format":"4D", "group_layout_name":"", "channel_layout_name":"" },{ "id":"default", "name":"import_channel", "description":"Select the group and name of the sensor layout. See bst_defaults/bst_eeg_layouts.json file and select all params from there", "group_layout_name":"ICBM152", "channel_layout_name":"10-20 19" } ] }, "channel_label_file":""}
Expand Down
7 changes: 4 additions & 3 deletions external/script_tess_force_envelope.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [NewTessFile, iSurface] = script_tess_force_envelope(TessFile, EnvFile, subject_report_path)
function [NewTessFile, iSurface] = script_tess_force_envelope(TessFile, EnvFile)
% TESS_FORCE_ENVELOPE: Forces the vertices of a surface to fit entirely in an envelope.
%
% USAGE: [NewTessFile, iSurface] = tess_force_envelope(TessFile, EnvFile)
Expand Down Expand Up @@ -160,6 +160,7 @@

% Display modified surface
if(getGlobalVerbose())
report_path = get_report_path(CiftiStorm, subID);
hFig_after = view_surface(NewTessFile, [], [], 'NewFigure');
panel_surface('SetSurfaceEdges', hFig_after, 1, 1);
view_surface(EnvFile, [], [], hFig_after);
Expand All @@ -174,7 +175,7 @@
'colorbars',{'off','off','off','off'},...
'view_orient',{[0,90],[1,270],[1,180],[0,360]});
bst_report('Snapshot',fig_out,[],'Cortex view before force the vertices inside of InnerSkull.', [200,200,900,700]);
savefig( hFig_before,fullfile(subject_report_path,fig_text));
savefig( hFig_before,fullfile(report_path,fig_text));
close(fig_out);
fig_text = strcat("Distance corrected - ",desc{2});
figures = {hFig_after, hFig_after, hFig_after, hFig_after};
Expand All @@ -183,7 +184,7 @@
'colorbars',{'off','off','off','off'},...
'view_orient',{[0,90],[1,270],[1,180],[0,360]});
bst_report('Snapshot',fig_out,[],'Cortex view. All cortex vertices are already inside the inner skull.', [200,200,900,700]);
savefig( hFig_after,fullfile(subject_report_path,fig_text));
savefig( hFig_after,fullfile(report_path,fig_text));
close(fig_out);
end
close([hFig_before,hFig_after]);
Expand Down
1 change: 1 addition & 0 deletions functions/cfs_process_interface.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
subjects = subjects.Subject;
case false
if(isequal(lower(anatomy_type.id),'default'))
CiftiStorm.Location = fullfile(general_params.output_path,strcat('ciftistorm-',anatomy_type.template_name));
subjects.name = anatomy_type.template_name;
sTemplates = bst_get('AnatomyDefaults');
sTemplate = sTemplates(find(strcmpi(subjects.name, {sTemplates.Name}),1));
Expand Down
19 changes: 6 additions & 13 deletions functions/export/create_report_path.m
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
function create_report_path(properties, subID)
function create_report_path(CiftiStorm, subID)

%%
%% Checking the report output structure
%%
ProtocolName = properties.general_params.bst_config.protocol_name;
output_path = properties.general_params.output_path;
output_path = CiftiStorm.Location;
if(output_path == "local")
output_path = pwd;
end
if(~isfolder(output_path))
mkdir(output_path);
end
if(~isfolder(fullfile(output_path,'ciftistorm')))
mkdir(fullfile(output_path,'ciftistorm'));
if(~isfolder(fullfile(output_path,'Reports')))
mkdir(fullfile(output_path,'Reports'));
end
if(~isfolder(fullfile(output_path,'ciftistorm',subID)))
mkdir(fullfile(output_path,'ciftistorm',subID));
end
if(~isfolder(fullfile(output_path,'brainstorm')))
mkdir(fullfile(output_path,'brainstorm'));
end
if(~isfolder(fullfile(output_path,'brainstorm','Reports')))
mkdir(fullfile(output_path,'brainstorm','Reports'));
if(~isfolder(fullfile(output_path,'Reports',subID)))
mkdir(fullfile(output_path,'Reports',subID));
end
end

5 changes: 2 additions & 3 deletions functions/export/export_subject_structure.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function export_error = export_subject_structure(properties,subID,CSurfaces,sub_to_FSAve, AQCI)
function export_error = export_subject_structure(CiftiStorm,subID,CSurfaces,sub_to_FSAve, AQCI)

%%
%% Get Protocol information
Expand All @@ -8,7 +8,7 @@
% Get subject directory
ProtocolInfo = bst_get('ProtocolInfo');
sSubject = bst_get('Subject', subID);
output_path = properties.general_params.output_path;
base_path = CiftiStorm.Location;


% Get the current Study
Expand Down Expand Up @@ -46,7 +46,6 @@
%%
%% Saving files in BC-VARETA Structure
%%
base_path = fullfile(output_path,'ciftistorm');
save_output_files(base_path, modality, subID, HeadModels, Cdata, Shead, Sout, Sinn, Scortex, AQCI);

end
Expand Down
7 changes: 3 additions & 4 deletions functions/export/get_report_path.m
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
function report_path = get_report_path(properties, subID)
function report_path = get_report_path(CiftiStorm, subID)

%%
%% Checking the report output structure
%%
ProtocolName = properties.general_params.bst_config.protocol_name;
output_path = properties.general_params.output_path;
output_path = CiftiStorm.Location;
if(output_path == "local")
output_path = pwd;
end
report_path = fullfile(output_path,'brainstorm','Reports',subID);
report_path = fullfile(output_path,'Reports',subID);
if(~isfolder(report_path))
mkdir(report_path);
end
Expand Down
6 changes: 1 addition & 5 deletions functions/processes/process_canonical_surfaces.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

errMessage = [];
mq_control = properties.general_params.bst_config.after_MaQC.run;
%%
%% Getting report path
%%
report_path = get_report_path(properties, subID);

%%
%% Compute SPM canonical surfaces
%%
Expand All @@ -21,6 +16,7 @@
%%
% Get subject definition and subject files
if(getGlobalVerbose())
report_path = get_report_path(CiftiStorm, subID);
sSubject = bst_get('Subject', subID);
MriFile = sSubject.Anatomy(sSubject.iAnatomy).FileName;
ScalpFile = sSubject.Surface(sSubject.iScalp).FileName;
Expand Down
8 changes: 2 additions & 6 deletions functions/processes/process_compute_surfaces.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
mq_control = properties.general_params.bst_config.after_MaQC.run;
nvertices = properties.anatomy_params.common_params.surfaces_resolution.nvertices;

%%
%% Getting report path
%%
report_path = get_report_path(properties, subID);

%%
%% Compute surfaces like BigBrain
%%
Expand Down Expand Up @@ -92,7 +87,7 @@
if(~isempty(CSurface.name) && isequal(CSurface.type,'cortex'))
CortexFile = Surfaces(CSurface.iSurface).FileName;
% [NewTessFile, iSurface] = tess_force_envelope(CortexFile, InnerSkullFile);
[NewTessFile, iSurface] = script_tess_force_envelope(CortexFile, InnerSkullFile, report_path);
[NewTessFile, iSurface] = script_tess_force_envelope(CortexFile, InnerSkullFile);
if(~isempty(iSurface))
CSurfaces(i).comment = strcat(CSurface.comment,'_fix');
CSurfaces(i).iSurface = iSurface;
Expand Down Expand Up @@ -163,6 +158,7 @@
%% Quality control
%%
if(getGlobalVerbose())
report_path = get_report_path(CiftiStorm, subID);
[sSubject, ~] = bst_get('Subject', subID);
Surfaces = sSubject.Surface;
for i=1:length(CSurfaces)
Expand Down
4 changes: 3 additions & 1 deletion functions/processes/process_create_subject.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
end
db_reload_database('current');
db_add_subject(subID);
create_report_path(properties, subID);
if(getGlobalVerbose())
create_report_path(CiftiStorm, subID);
end
else
gui_brainstorm('UpdateProtocolsList');
iProtocol = bst_get('Protocol', ProtocolName);
Expand Down
4 changes: 2 additions & 2 deletions functions/processes/process_export_subject.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

errMessage = [];
if(isequal(properties.anatomy_params.anatomy_type.id,'individual'))
output_path = fullfile(properties.general_params.output_path,'brainstorm');
output_path = CiftiStorm.Location;
else
template_name = properties.anatomy_params.anatomy_type.template_name;
output_path = fullfile(properties.general_params.output_path,strcat('brainstorm-',template_name));
Expand All @@ -26,7 +26,7 @@
%%
if(getGlobalVerbose())
disp("-->> Export BST Report");
report_path = get_report_path(properties, subID);
report_path = get_report_path(CiftiStorm, subID);
ReportFile = bst_report('Save', []);
bst_report('Export', ReportFile, fullfile(report_path,[subID,'.html']));
end
Expand Down
5 changes: 1 addition & 4 deletions functions/processes/process_gen_bem_surfaces.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

errMessage = [];
mq_control = properties.general_params.bst_config.after_MaQC.run;
%%
%% Getting report path
%%
report_path = get_report_path(properties, subID);

%%
%% Compute BEM Surfaces
Expand Down Expand Up @@ -48,6 +44,7 @@
%% Quality control
%%
if(getGlobalVerbose())
report_path = get_report_path(CiftiStorm, subID);
sSubject = bst_get('Subject', subID);
Surfaces = sSubject.Surface;
CortexFile = Surfaces(sSubject.iCortex).FileName;
Expand Down
6 changes: 2 additions & 4 deletions functions/processes/process_import_anat.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,12 @@
end
end

%%
%% Getting report path
%%
report_path = get_report_path(properties, subID);

%%
%% Quality control
%%
% Get MRI file and surface files
report_path = get_report_path(CiftiStorm, subID);
if(getGlobalVerbose())
[sSubject,~] = bst_get('Subject', subID);
MriFile = sSubject.Anatomy(sSubject.iAnatomy).FileName;
Expand Down
2 changes: 1 addition & 1 deletion functions/processes/process_import_atlas.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
%%
%% Getting report path and params
%%
report_path = get_report_path(properties, subID);
errMessage = [];
anatomy_type = properties.anatomy_params.anatomy_type;
type = anatomy_type.id;
Expand Down Expand Up @@ -54,6 +53,7 @@
%% Quality control
%%
if(getGlobalVerbose())
report_path = get_report_path(CiftiStorm, subID);
panel_scout('SetScoutsOptions', 0, 0, 1, 'all', 1, 0, 0, 0);
panel_scout('UpdateScoutsDisplay', 'all');
panel_scout('SetScoutContourVisible', 0, 0);
Expand Down
7 changes: 1 addition & 6 deletions functions/processes/process_import_chann.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
sSubject = bst_get('Subject', subID);
type = properties.channel_params.channel_type.id;


%%
%% Getting report path
%%
report_path = get_report_path(properties, subID);

if(~mq_control)
%%
%% ===== IMPORT CHANNEL =====
Expand Down Expand Up @@ -151,6 +145,7 @@
%%
%%
if(getGlobalVerbose())
report_path = get_report_path(CiftiStorm, subID);
if(isequal(properties.general_params.modality,'EEG'))
hFigMri16 = script_view_mri_3d(MriFile, [], [], [], 'front');
hFigMri16 = view_channels(ChannelFile, 'EEG', 1, 0, hFigMri16, 1);
Expand Down
15 changes: 4 additions & 11 deletions functions/processes/process_integration.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,8 @@
% Get subject directory
ProtocolInfo = bst_get('ProtocolInfo');
sSubject = bst_get('Subject', subID);
general_params = properties.general_params;
base_path = CiftiStorm.Location;

if(isequal(properties.anatomy_params.anatomy_type.id,'individual'))
base_path = fullfile(general_params.output_path,'ciftistorm');
else
template_name = properties.anatomy_params.anatomy_type.template_name;
base_path = fullfile(general_params.output_path,strcat('ciftistorm-',template_name));
end

% Get the current Study
[sStudies, ~] = bst_get('StudyWithSubject', sSubject.FileName, 'intra_subject');
Expand Down Expand Up @@ -68,12 +62,11 @@
CiftiStorm.Participants(end).Process(end).Error = [];
else
CiftiStorm.Template = CiftiStorm.Participants;
disp(strcat("-->> Saving anatomy template: ",template_name));
disp(strcat("-->> Saving anatomy template: ",subID));
disp("--------------------------------------------------------------------------");
CiftiStorm.Template.SubID = template_name;
CiftiStorm.Template.SubID = subID;
CiftiStorm.Template.Status = "Anatomy";
CiftiStorm.Template.FileInfo = strcat(template_name,'.json');
subID = template_name;
CiftiStorm.Template.FileInfo = strcat(subID,'.json');
HeadModels = rawHeadModels;
Cdata = rawCdata;
AQCI = AutomaticQCI(HeadModels.HeadModel.Gain, Cdata, Scortex.Sc);
Expand Down
Loading