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

Enhance the LF viewer and adding more options from the keyboard #343

Merged
merged 6 commits into from
Oct 31, 2020

Conversation

tmedani
Copy link
Member

@tmedani tmedani commented Oct 16, 2020

Hi @ftadel,

This PR is to complete the PR that @juangpc proposed (#337 (comment)), and it includes also the proposed option.

It includes useful options to visualize and manipulate the LF vectors, all these options are managed from keyboard shortcuts, they can be displayed with the 'H' keyboard key, as in this figure :

image

With this version, the average reference option can be also selected from the same list as the channels (R) instead to have multiple popup panels, the "target channels (T) can be also selected from a dedicated list, which is useful in the case where users want to see the LF between two specific channels.

There are also functions that change the scale, the length, and the width of the vectors. Furthermore, there is a way to threshold the displayed vectors by fixing the Amplitude threshold as shown in the figure. All this interactively with the figure & the keyboard (as usual with Branstom figure 👍 ).

For the standard view keyboard (1-9), I have used the same subfunctions "SetStandardView" that I have copy-pasted to this function.

All these options are for visualization purposes, the next dev should focus on functions that can
quantitatively compare these differents LF models.

Also, the idea behind these new options is not only for the LF, but also to extend the use for the optical flow (#311), as previously discussed with @LeoNouvelle @martcous & @sbaillet

I hope this will be useful :)

A+
Takfarinas

iChannel = 1;
iQuiverSize = 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The convention in the rest of the code is "iVariableName" being an index.
https://neuroimage.usc.edu/brainstorm/Tutorials/Scripting#Naming_conventions

These are not indices.
Can you please rename the variables?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok I will correct it,

'<TR><TD><B>Down arrow</B></TD><TD>Next ref channel (green color)</TD></TR>'....
'<TR><TD><B>Shift + uparrow</B></TD><TD>Increase the vector length</TD></TR>'...
'<TR><TD><B>Shift + downarrow</B></TD><TD>Decrease the vector length</TD></TR>'...
'<TR><TD><B>Shift + L</B></TD><TD>Toggle on/off logarithmic scale</TD></TR>'...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is "Shift + Enter" instead

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think both are working,
"Shift + Enter" and "Shift + L"

'</TABLE>'], 'Keyboard shortcuts');

% === NUMBERS : VIEW SHORTCUTS ===
case '0'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delegate all this to figure_3d instead.
In the otherwise block, it should call figure_3d/FigureKeyPressedCallback and set the orientation.
Or am I missing something?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right,
I did not manage to link the current function with the figure_3d

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The block otherwise in the switch calls KeyPressFcn_bak(hQuiver, keyEvent), which actually calls the original handler from figure_3d (figure_3d/FigureKeyPressedCallback). You don't have to do add anything so that figure_3d processes the orientation keys.
If you have any trouble, add a breakpoint at the beginning of figure_3d/FigureKeyPressedCallback to check what is wrong.

In general, if you need to call a function in a different file, use the syntax figure_3d('FunctionName', param1, param2...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I got it, the problem was in the figure handles,
image

Now it's working.

Thanks :)

function GetLeadField
% Update the LF according to the selected channels only
for iLF = 1:length(HeadmodelFiles)
LF_finale{iLF} = HeadmodelMat{iLF}.Gain(iChannels,:);
end
end

%% ===== LEADFIELD TO LOG SPACE =====
function lf_log = logScaledLeadField(lf)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is a function, it would be better if it were named as an action.
For example: ScaleLeadfield

But since this is called only once and not very long, I suggest you integrate it directly into where it is required.
(and not keep it as a separate function)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I will correct it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, This is just an open comment. Please don't modify your intentions.

  • the integration of the scaling function in the main flow. I personally wouldn't integrate it. Keeping simple, atomic, operations in a codebase, abstracted of everything else, as much as possible, I think makes the code easier to follow, debug and, eventually, reuse code, etc... This might be a bad example because of its simplicity, but still.
  • Totally agree with the renaming. Would suggest LogScaleLeadfield, but ScaleLeadfield is just fine.
    Thanks for reading.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I have corrected the PR according to the discussion, and regarding this comment I changed only the name of the sub-function "ScaleLeadfield", I think also it's more convenient to have as a subfunction, but this is also my comment.
so, @ftadel if you don't like it I will change it :)


%= = From this line, these functions are part of the figure3d
%% ===== SET STANDARD VIEW =====
function SetStandardView(hFig, viewNames)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why you copy-pasted a function from figure_3d here.
If you need to call a function in a different file, use the syntax figure_3d('FunctionName', param1, param2...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not manage to use figure_3d in this function, but if you think it's possible I will try to do it.

@ftadel ftadel merged commit 45d7c1d into brainstorm-tools:master Oct 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants