cpp-lln-lab / CPP_PTB

a set of function to make it easier to create behavioral, EEG, fMRI experiment with psychtoolbox
https://cpp-ptb.readthedocs.io/en/latest/index.html#
MIT License
14 stars 13 forks source link

[BUG]: unfold does not print a new line at the end of the struc #175

Closed marcobarilari closed 2 years ago

marcobarilari commented 2 years ago

Is there an existing issue for this?

Expected Behavior

cfg.timing.onsetDelay = 0.000000;
cfg.timing.triggerIBI = 4.000000;
cfg.verbose =   1.000000;
>> 

Current Behavior

cfg.timing.onsetDelay = 0.000000;
cfg.timing.triggerIBI = 4.000000;
cfg.verbose =   1.000000;>> 

Error message

No error message, just esthetics

Environment

- OS:
- Matlab:
- SPM:

Anything else?

Writing this here but it is valid for any repo with unfold that btw it is amazing :)

Remi-Gau commented 2 years ago

Yup I tried to fix this but because the function is recursive it ended also skipping a million lines in the middle of the output. Dirty hack in CPP SPM was creating a new function called unfoldStruct that calls unfold and adds a line after.

marcobarilari commented 2 years ago

yep, likewise. I tried but it was skipping lines

Remi-Gau commented 2 years ago

Actually need to check but it should be doable to check the status of the call stack and only print an extra line if the unfold is the last function on the stack... Not sure if I am talking English here...

marcobarilari commented 2 years ago

No, it is clear, this is a devil function that calls itself

Remi-Gau commented 2 years ago

I think I fixed it with this at the end of the function:

  callStack = dbstack();
  if numel(callStack) > 1 && ~strcmp(callStack(2).name, mfilename())
    fprintf('\n');
  elseif numel(callStack) == 1 && strcmp(callStack(1).name, mfilename())
    fprintf('\n');
  end