From fc0c537812c3090c64d1900d1c1c1055ed4b5872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Blanca=20Zufiria=20Gerbol=C3=A9s?= <112950493+bzufiriaki@users.noreply.github.com> Date: Mon, 23 Oct 2023 09:46:30 +0200 Subject: [PATCH] Bz layer number (#1673; BZ) Co-authored-by: Giovanni Volpe <46021832+giovannivolpe@users.noreply.github.com> --- .../connectivity multiplex/SubjectCON_MP.m | 71 +++++++++++++++++++ .../functional multiplex/SubjectFUN_MP.m | 71 +++++++++++++++++++ .../structural multiplex/SubjectST_MP.m | 71 +++++++++++++++++++ .../_SubjectCON_MP.gen.m | 27 ++++++- .../functional multiplex/_SubjectFUN_MP.gen.m | 27 ++++++- .../structural multiplex/_SubjectST_MP.gen.m | 27 ++++++- 6 files changed, 291 insertions(+), 3 deletions(-) diff --git a/braph2/pipelines/connectivity multiplex/SubjectCON_MP.m b/braph2/pipelines/connectivity multiplex/SubjectCON_MP.m index a7116c137d..8673c61849 100644 --- a/braph2/pipelines/connectivity multiplex/SubjectCON_MP.m +++ b/braph2/pipelines/connectivity multiplex/SubjectCON_MP.m @@ -600,6 +600,30 @@ prop_default = SubjectCON_MP.conditioning(prop, SubjectCON_MP.getPropDefault(prop)); end end + methods (Access=protected) % preset + function value = preset(sub, prop, value) + %PRESET preprocesses the value of a property before setting it. + % + % VALUE = PRESET(EL, PROP, VALUE) prepropcesses the VALUE of the property + % PROP. It works only with properties with 2, + % 3, 4, 8 and 9. By + % default, this function does not do anything, so it should be implemented + % in the subclasses of Element when needed. + % + % See also conditioning, checkProp, postset, postprocessing, + % calculateValue, checkValue. + + switch prop + case 11 % SubjectCON_MP.L + value = abs(round(value)); + + otherwise + if prop <= 9 + value = preset@Subject(sub, prop, value); + end + end + end + end methods (Static) % checkProp function prop_check = checkProp(pointer, value) %CHECKPROP checks whether a value has the correct format/error. @@ -661,6 +685,53 @@ end end end + methods (Access=protected) % postset + function postset(sub, prop) + %POSTSET postprocessing after a prop has been set. + % + % POSTPROCESSING(EL, PROP) postprocessesing after PROP has been set. By + % default, this function does not do anything, so it should be implemented + % in the subclasses of Element when needed. + % + % This postprocessing occurs only when PROP is set. + % + % See also conditioning, preset, checkProp, postprocessing, calculateValue, + % checkValue. + + switch prop + case 11 % SubjectCON_MP.L + if ~isa(sub.getr('CON_MP'), 'NoValue') && sub.get('L') ~= length(sub.get('CON_MP')) + sub.set('L', length(sub.get('CON_MP'))) + end + + case 12 % SubjectCON_MP.LAYERLABELS + if ~isa(sub.getr('L'), 'NoValue') && length(sub.get('LAYERLABELS')) == sub.get('L') + title = ['About Layer Labels']; + + message = {'' + ['{\bf\color{orange}' 'BRAPH2' '}'] % note to use doubl slashes to avoid genesis problem + ['{\color{gray}version ' '2.0.0.b2' '}'] + ['{\color{gray}build ' int2str(6) '}'] + '' + 'Please, select a valid number of Layer Labels.' + '' + ''}; + braph2msgbox(title, message) + sub.set('LAYERLABELS', cat(1, strsplit(num2str(1:1:length(sub.get('CON_MP')))))) + end + + case 14 % SubjectCON_MP.CON_MP + if length(sub.get('LAYERLABELS')) ~= sub.get('L') + sub.set('LAYERLABELS', cat(1, strsplit(num2str(1:1:length(sub.get('CON_MP')))))) + end + + otherwise + if prop <= 9 + postset@Subject(sub, prop); + end + end + end + end methods (Access=protected) % calculate value function value = calculateValue(sub, prop, varargin) %CALCULATEVALUE calculates the value of a property. diff --git a/braph2/pipelines/functional multiplex/SubjectFUN_MP.m b/braph2/pipelines/functional multiplex/SubjectFUN_MP.m index cc48a8cda6..48d494cda3 100644 --- a/braph2/pipelines/functional multiplex/SubjectFUN_MP.m +++ b/braph2/pipelines/functional multiplex/SubjectFUN_MP.m @@ -600,6 +600,30 @@ prop_default = SubjectFUN_MP.conditioning(prop, SubjectFUN_MP.getPropDefault(prop)); end end + methods (Access=protected) % preset + function value = preset(sub, prop, value) + %PRESET preprocesses the value of a property before setting it. + % + % VALUE = PRESET(EL, PROP, VALUE) prepropcesses the VALUE of the property + % PROP. It works only with properties with 2, + % 3, 4, 8 and 9. By + % default, this function does not do anything, so it should be implemented + % in the subclasses of Element when needed. + % + % See also conditioning, checkProp, postset, postprocessing, + % calculateValue, checkValue. + + switch prop + case 11 % SubjectFUN_MP.L + value = abs(round(value)); + + otherwise + if prop <= 9 + value = preset@Subject(sub, prop, value); + end + end + end + end methods (Static) % checkProp function prop_check = checkProp(pointer, value) %CHECKPROP checks whether a value has the correct format/error. @@ -661,6 +685,53 @@ end end end + methods (Access=protected) % postset + function postset(sub, prop) + %POSTSET postprocessing after a prop has been set. + % + % POSTPROCESSING(EL, PROP) postprocessesing after PROP has been set. By + % default, this function does not do anything, so it should be implemented + % in the subclasses of Element when needed. + % + % This postprocessing occurs only when PROP is set. + % + % See also conditioning, preset, checkProp, postprocessing, calculateValue, + % checkValue. + + switch prop + case 11 % SubjectFUN_MP.L + if ~isa(sub.getr('FUN_MP'), 'NoValue') && sub.get('L') ~= length(sub.get('FUN_MP')) + sub.set('L', length(sub.get('FUN_MP'))) + end + + case 12 % SubjectFUN_MP.LAYERLABELS + if ~isa(sub.getr('L'), 'NoValue') && length(sub.get('LAYERLABELS')) ~= sub.get('L') + title = ['About Layer Labels']; + + message = {'' + ['{\bf\color{orange}' 'BRAPH2' '}'] % note to use doubl slashes to avoid genesis problem + ['{\color{gray}version ' '2.0.0.b2' '}'] + ['{\color{gray}build ' int2str(6) '}'] + '' + 'Please, select a valid number of Layer Labels.' + '' + ''}; + braph2msgbox(title, message) + sub.set('LAYERLABELS', cat(1, strsplit(num2str(1:1:length(sub.get('FUN_MP')))))) + end + + case 14 % SubjectFUN_MP.FUN_MP + if length(sub.get('LAYERLABELS')) ~= sub.get('L') + sub.set('LAYERLABELS', cat(1, strsplit(num2str(1:1:length(sub.get('FUN_MP')))))) + end + + otherwise + if prop <= 9 + postset@Subject(sub, prop); + end + end + end + end methods (Access=protected) % calculate value function value = calculateValue(sub, prop, varargin) %CALCULATEVALUE calculates the value of a property. diff --git a/braph2/pipelines/structural multiplex/SubjectST_MP.m b/braph2/pipelines/structural multiplex/SubjectST_MP.m index d769b3eed6..de9ba8a4ad 100644 --- a/braph2/pipelines/structural multiplex/SubjectST_MP.m +++ b/braph2/pipelines/structural multiplex/SubjectST_MP.m @@ -600,6 +600,30 @@ prop_default = SubjectST_MP.conditioning(prop, SubjectST_MP.getPropDefault(prop)); end end + methods (Access=protected) % preset + function value = preset(sub, prop, value) + %PRESET preprocesses the value of a property before setting it. + % + % VALUE = PRESET(EL, PROP, VALUE) prepropcesses the VALUE of the property + % PROP. It works only with properties with 2, + % 3, 4, 8 and 9. By + % default, this function does not do anything, so it should be implemented + % in the subclasses of Element when needed. + % + % See also conditioning, checkProp, postset, postprocessing, + % calculateValue, checkValue. + + switch prop + case 11 % SubjectST_MP.L + value = abs(round(value)); + + otherwise + if prop <= 9 + value = preset@Subject(sub, prop, value); + end + end + end + end methods (Static) % checkProp function prop_check = checkProp(pointer, value) %CHECKPROP checks whether a value has the correct format/error. @@ -661,6 +685,53 @@ end end end + methods (Access=protected) % postset + function postset(sub, prop) + %POSTSET postprocessing after a prop has been set. + % + % POSTPROCESSING(EL, PROP) postprocessesing after PROP has been set. By + % default, this function does not do anything, so it should be implemented + % in the subclasses of Element when needed. + % + % This postprocessing occurs only when PROP is set. + % + % See also conditioning, preset, checkProp, postprocessing, calculateValue, + % checkValue. + + switch prop + case 11 % SubjectST_MP.L + if ~isa(sub.getr('ST_MP'), 'NoValue') && sub.get('L') ~= length(sub.get('ST_MP')) + sub.set('L', length(sub.get('ST_MP'))) + end + + case 12 % SubjectST_MP.LAYERLABELS + if ~isa(sub.getr('L'), 'NoValue') && length(sub.get('LAYERLABELS')) == sub.get('L') + title = ['About Layer Labels']; + + message = {'' + ['{\bf\color{orange}' 'BRAPH2' '}'] % note to use doubl slashes to avoid genesis problem + ['{\color{gray}version ' '2.0.0.b2' '}'] + ['{\color{gray}build ' int2str(6) '}'] + '' + 'Please, select a valid number of Layer Labels.' + '' + ''}; + braph2msgbox(title, message) + sub.set('LAYERLABELS', cat(1, strsplit(num2str(1:1:length(sub.get('ST_MP')))))) + end + + case 14 % SubjectST_MP.ST_MP + if length(sub.get('LAYERLABELS')) ~= sub.get('L') + sub.set('LAYERLABELS', cat(1, strsplit(num2str(1:1:length(sub.get('ST_MP')))))) + end + + otherwise + if prop <= 9 + postset@Subject(sub, prop); + end + end + end + end methods (Access=protected) % calculate value function value = calculateValue(sub, prop, varargin) %CALCULATEVALUE calculates the value of a property. diff --git a/braph2genesis/pipelines/connectivity multiplex/_SubjectCON_MP.gen.m b/braph2genesis/pipelines/connectivity multiplex/_SubjectCON_MP.gen.m index d44e672029..18c69d03c8 100644 --- a/braph2genesis/pipelines/connectivity multiplex/_SubjectCON_MP.gen.m +++ b/braph2genesis/pipelines/connectivity multiplex/_SubjectCON_MP.gen.m @@ -199,9 +199,30 @@ function cb_exporter_XLS(~, ~) L (data, scalar) is the number of layers of subject data. %%%% ¡default! 2 +%%%% ¡preset! +value = abs(round(value)); +%%%% ¡postset! +if ~isa(sub.getr('CON_MP'), 'NoValue') && sub.get('L') ~= length(sub.get('CON_MP')) + sub.set('L', length(sub.get('CON_MP'))) +end %%% ¡prop! LAYERLABELS (metadata, stringlist) are the layer labels provided by the user. +%%%% ¡postset! +if ~isa(sub.getr('L'), 'NoValue') && length(sub.get('LAYERLABELS')) ~= sub.get('L') + title = ['About Layer Labels']; + message = {'' + ['{\\bf\\color{orange}' BRAPH2.STR '}'] % note to use doubl slashes to avoid genesis problem + ['{\\color{gray}version ' BRAPH2.VERSION '}'] + ['{\\color{gray}build ' int2str(BRAPH2.BUILD) '}'] + '' + 'Please, select a valid number of Layer Labels.' + '' + ''}; + braph2msgbox(title, message) + + sub.set('LAYERLABELS', cat(1, strsplit(num2str(1:1:length(sub.get('CON_MP')))))) +end %%% ¡prop! ALAYERLABELS (query, stringlist) returns the processed layer labels. @@ -219,6 +240,10 @@ function cb_exporter_XLS(~, ~) else msg = ['CON_MP must be a cell with L square matrices with the dimensiton equal to the number of brain regions (' int2str(br_number) ').']; end +%%%% ¡postset! +if length(sub.get('LAYERLABELS')) ~= sub.get('L') + sub.set('LAYERLABELS', cat(1, strsplit(num2str(1:1:length(sub.get('CON_MP')))))) +end %%%% ¡gui! pr = PanelPropCell('EL', sub, 'PROP', SubjectCON_MP.CON_MP, ... 'TABLE_HEIGHT', s(40), ... @@ -260,4 +285,4 @@ function cb_exporter_XLS(~, ~) gui.get('DRAW') gui.get('SHOW') -gui.get('CLOSE') \ No newline at end of file +gui.get('CLOSE') diff --git a/braph2genesis/pipelines/functional multiplex/_SubjectFUN_MP.gen.m b/braph2genesis/pipelines/functional multiplex/_SubjectFUN_MP.gen.m index 80c77571b1..155f758803 100644 --- a/braph2genesis/pipelines/functional multiplex/_SubjectFUN_MP.gen.m +++ b/braph2genesis/pipelines/functional multiplex/_SubjectFUN_MP.gen.m @@ -199,9 +199,30 @@ function cb_exporter_XLS(~, ~) L (data, scalar) is the number of layers of subject data. %%%% ¡default! 2 +%%%% ¡preset! +value = abs(round(value)); +%%%% ¡postset! +if ~isa(sub.getr('FUN_MP'), 'NoValue') && sub.get('L') ~= length(sub.get('FUN_MP')) + sub.set('L', length(sub.get('FUN_MP'))) +end %%% ¡prop! LAYERLABELS (metadata, stringlist) are the layer labels provided by the user. +%%%% ¡postset! +if ~isa(sub.getr('L'), 'NoValue') && length(sub.get('LAYERLABELS')) ~= sub.get('L') + title = ['About Layer Labels']; + message = {'' + ['{\\bf\\color{orange}' BRAPH2.STR '}'] % note to use doubl slashes to avoid genesis problem + ['{\\color{gray}version ' BRAPH2.VERSION '}'] + ['{\\color{gray}build ' int2str(BRAPH2.BUILD) '}'] + '' + 'Please, select a valid number of Layer Labels.' + '' + ''}; + braph2msgbox(title, message) + + sub.set('LAYERLABELS', cat(1, strsplit(num2str(1:1:length(sub.get('FUN_MP')))))) +end %%% ¡prop! ALAYERLABELS (query, stringlist) returns the processed layer labels. @@ -219,6 +240,10 @@ function cb_exporter_XLS(~, ~) else msg = ['FUN_MP must be a cell with L matrices with the same number of columns as the number of brain regions (' int2str(br_number) ').']; end +%%%% ¡postset! +if length(sub.get('LAYERLABELS')) ~= sub.get('L') + sub.set('LAYERLABELS', cat(1, strsplit(num2str(1:1:length(sub.get('FUN_MP')))))) +end %%%% ¡gui! pr = PanelPropCell('EL', sub, 'PROP', SubjectFUN_MP.FUN_MP, ... 'TABLE_HEIGHT', s(40), ... @@ -260,4 +285,4 @@ function cb_exporter_XLS(~, ~) gui.get('DRAW') gui.get('SHOW') -gui.get('CLOSE') \ No newline at end of file +gui.get('CLOSE') diff --git a/braph2genesis/pipelines/structural multiplex/_SubjectST_MP.gen.m b/braph2genesis/pipelines/structural multiplex/_SubjectST_MP.gen.m index 53998f9c07..a8c44b3303 100644 --- a/braph2genesis/pipelines/structural multiplex/_SubjectST_MP.gen.m +++ b/braph2genesis/pipelines/structural multiplex/_SubjectST_MP.gen.m @@ -199,9 +199,30 @@ function cb_exporter_XLS(~, ~) L (data, scalar) is the number of layers of subject data. %%%% ¡default! 2 +%%%% ¡preset! +value = abs(round(value)); +%%%% ¡postset! +if ~isa(sub.getr('ST_MP'), 'NoValue') && sub.get('L') ~= length(sub.get('ST_MP')) + sub.set('L', length(sub.get('ST_MP'))) +end %%% ¡prop! LAYERLABELS (metadata, stringlist) are the layer labels provided by the user. +%%%% ¡postset! +if ~isa(sub.getr('L'), 'NoValue') && length(sub.get('LAYERLABELS')) ~= sub.get('L') + title = ['About Layer Labels']; + message = {'' + ['{\\bf\\color{orange}' BRAPH2.STR '}'] % note to use doubl slashes to avoid genesis problem + ['{\\color{gray}version ' BRAPH2.VERSION '}'] + ['{\\color{gray}build ' int2str(BRAPH2.BUILD) '}'] + '' + 'Please, select a valid number of Layer Labels.' + '' + ''}; + braph2msgbox(title, message) + + sub.set('LAYERLABELS', cat(1, strsplit(num2str(1:1:length(sub.get('ST_MP')))))) +end %%% ¡prop! ALAYERLABELS (query, stringlist) returns the processed layer labels. @@ -219,6 +240,10 @@ function cb_exporter_XLS(~, ~) else msg = ['ST_MP must be a column vector with the same number of element as the brain regions (' int2str(br_number) ').']; end +%%%% ¡postset! +if length(sub.get('LAYERLABELS')) ~= sub.get('L') + sub.set('LAYERLABELS', cat(1, strsplit(num2str(1:1:length(sub.get('ST_MP')))))) +end %%%% ¡gui! pr = PanelPropCell('EL', sub, 'PROP', SubjectST_MP.ST_MP, ... 'TABLE_HEIGHT', s(40), ... @@ -260,4 +285,4 @@ function cb_exporter_XLS(~, ~) gui.get('DRAW') gui.get('SHOW') -gui.get('CLOSE') \ No newline at end of file +gui.get('CLOSE')