Skip to content

Added command options for mrview:#961

Merged
jdtournier merged 18 commits intoMRtrix3:tag_3.0_RC2from
LeeReid1:master
Aug 4, 2017
Merged

Added command options for mrview:#961
jdtournier merged 18 commits intoMRtrix3:tag_3.0_RC2from
LeeReid1:master

Conversation

@LeeReid1
Copy link
Copy Markdown
Contributor

tractography.load (loads a track file)
tractography.slab (slab thickness, or -1 for unlimited)
tractography.tsf (uses a tsf file for track node colours)
WARNING: tsf optional arguments do not appear to actually be optional due to pre-existing code enforcing 'optional' args (bug?).

Edits work, but may require a slight tidy to match expected patterns etc. I've never touched QT before!

rei19q and others added 2 commits April 10, 2017 13:43
tractography.load (loads a track file)
tractography.slab (slab thickness)
tractography.tsf (uses a tsf file for track node colours)
WARNING: tsf optional arguments do not appear to actually be optional due to pre-existing code enforcing 'optional' args (bug?).
@maxpietsch
Copy link
Copy Markdown
Member

maxpietsch commented Apr 10, 2017

Can confirm that tractography.slab works.
tractography.tsf works except for the described problem with the default argument.

Arguments can be declared optiona; but, as far as I know, there is no way of specifying an Argument to an Option as optional. So I'd suggest using separate options instead:

+ Option ("tractography.tsf_load", "Load the track scalar file. Filename ").allow_multiple()
+ Argument("tsf").type_file_in()

+ Option ("tractography.tsf_range", "Set range for the track scalar file.  RangeMin,RangeMax").allow_multiple()
+ Argument("range").type_sequence_float()

+ Option ("tractography.tsf_thresh", "Set thresholds for the track scalar file.  ThresholdMin,ThesholdMax").allow_multiple()
+ Argument("thresh").type_sequence_float()

Alternatively, it might make sense to implement optional arguments for options to keep the command line options a bit tidier.

@jdtournier
Copy link
Copy Markdown
Member

OK, had a quick look into this. I agree with @maxpietsch that it would be best to split off the different settings into different options. And it's indeed not possible to have optional arguments to options, otherwise a command like this can't be parsed correctly:

$ command argument1 -option mandatory_argument optional_argument argument2 ...

since optional_argument could legitimately be interpreted as main argument 2 - so it's fundamentally ambiguous.

Otherwise, I fixed up the indentation to use 2 white spaces rather than tabs - this is the standard we've settled on in MRtrix3. There might be a way to set your editor to do use this for this project.

The main issue you were facing was the fact that no tractogram was selected when you want to load the TSF. This would be better fixed by ensuring that the Tractography::tractogram_open_slot() call actually selected the newly loaded tractograms. This should immediately fix that problem, and also ensure correct operation when you want to load a TSF file that doesn't correspond to the last tractogram in the list (we would eventually need to add an option to choose which tractogram is selected).

I'm surprised that you'd need to manually invoke on_crop_to_slab_slot() and on_slab_thickness_slot(). This shouldn't be required, not sure why it's not behaving as expected...

I won't have time to look into this a great deal more over the next few days, but if you're feeling motivated, hopefully the above will give you some inspiration... 😉

@LeeReid1
Copy link
Copy Markdown
Contributor Author

This should immediately fix that problem, and also ensure correct operation when you want to load a TSF file that doesn't correspond to the last tractogram in the list (we would eventually need to add an option to choose which tractogram is selected).

The way it is set up at the moment means that the TSF file applies to the previously stated tractography file provided. This means you can do the following to apply two different tsf files to two different tck files:

mrview -tractography.load a.tck -tractography.tsf_load a.tsf -tractography.load b.tck -tractography.tsf_load b.tsf

I.E. a.tsf is applied to a.tck, and b.tsf is applied to b.tck.
I figure that this is intuitive for the user?

Modifying Tractography::tractogram_open_slot will not affect the current behaviour because this method is not used (this slot launches an open file dialog). I've now made a method called Tractography::select_last_added_tractogram that does what it says. If you want to call this from Tractography::tractogram_open_slot at some point in the future, now you can. :)

I'm surprised that you'd need to manually invoke on_crop_to_slab_slot() and on_slab_thickness_slot(). This shouldn't be required, not sure why it's not behaving as expected...

No idea! I was surprised too. Qt is foreign to me. Perhaps signals are suppressed by the class until things are drawn to screen or I made an error somewhere? Not critical at the moment.

Arguments can be declared optiona; but, as far as I know, there is no way of specifying an Argument to an Option as optional. So I'd suggest using separate options instead

Edited as suggested

@jdtournier
Copy link
Copy Markdown
Member

The way it is set up at the moment means that the TSF file applies to the previously stated tractography file provided.

I fully agree that it would work as expected, certainly as things stand. But I do think the correct solution here would be to fix the behaviour when a tractogram is added and make sure it is also selected at that point. It would make sense when interacting with the tool directly anyway. The Overlay tool does this, so it's probably a good example of how to get it to work.

Modifying Tractography::tractogram_open_slot will not affect the current behaviour because this method is not used (this slot launches an open file dialog).

Of course, you're right. The Overlay tool splits the open slot from the actual method that opens the images, so that the latter can be used programmatically. Ultimately, that would probably be favoured solution...

As to the issue with the update needed to be triggered manually, I can probably look into this when I have a minute (probably after the ISMRM though...).

@LeeReid1
Copy link
Copy Markdown
Contributor Author

LeeReid1 commented Apr 11, 2017 via email

… command line commands) to call a single method
@LeeReid1
Copy link
Copy Markdown
Contributor Author

Sorry for the delay. I've refactored the code as suggested. Opening a tractogram will now result in it being selected.

There is a bug (in the current version of MRtrix), and I'm not whether I introduced it or not in my previous commit. To replicate:

  1. Open MRview, open an image
  2. Open the tractography tool side bar
  3. Open a tractogram

The tractography file will load, but the side bar will not list the file until the window is resized.

@LeeReid1
Copy link
Copy Markdown
Contributor Author

Worth highlighting that the clang build is failing due to some change in the Eigen 3 library, not my code.

Checking memory alignment for Eigen 3.3 compatibility... FAIL

Compiling with g++-6 works fine

jdtournier and others added 5 commits May 19, 2017 15:00
This header should no longer be included directly, since class MR::vector (defined in core/types.h) should always be used.
As discussed in #996.
Also some other minor cosmetic changes.
@jdtournier
Copy link
Copy Markdown
Member

@LeeReidCSIRO, I finally found a bit of time to look through your suggestions. I made the very minor edits required to get it to pass the Eigen compatibility tests (I've yet to document these changes, so it's no surprise that it would catch people out...). The other changes are basically purely cosmetic. Everything seems to work fine from my side. The issue you mentioned with the sidebar not updating after tractography load until a resize isn't a problem for me. What version of Qt are you using...?

@maxpietsch
Copy link
Copy Markdown
Member

There is a bug (in the current version of MRtrix), and I'm not whether I introduced it or not in my previous commit. To replicate:

Open MRview, open an image
Open the tractography tool side bar
Open a tractogram
The tractography file will load, but the side bar will not list the file until the window is resized.

I can't reproduce this. Neither in our nor in LeeReidCSIRO's master branch. Loading a tractogram causes the toolbar to flicker so I think it gets updated.

@LeeReid1
Copy link
Copy Markdown
Contributor Author

Qt 4.8.6
Open GL 3.3
It's a Ubuntu 14.04 box.

@LeeReid1
Copy link
Copy Markdown
Contributor Author

@maxpietsch I think if it's working for you here, chances are it's a bug that's a little deeper than my commits.

@LeeReid1
Copy link
Copy Markdown
Contributor Author

Kerstin Pannek has just pointed the following:
Open Mrview with image --> add tck file --> not shown in toolbar until resize
but
Open Mrview with image --> maximise window --> add tck file --> no problems

@jdtournier
Copy link
Copy Markdown
Member

I've just had another quick go, I can't reproduce the issues you're reporting using either Qt 5.8.0 or Qt 4.8.7 (on Arch Linux). I have no idea why this might be happening. Could be an interaction with your window manager? We use Gnome Shell typically (or i3 for @maxpietsch...), maybe this is an issue specific to Unity...?

@jdtournier jdtournier changed the base branch from master to dev July 12, 2017 13:41
@jdtournier
Copy link
Copy Markdown
Member

Let's merge this into the dev branch with a view to making it part of the next tag release. I don't see any issues with it, other than the problems reported by @LeeReidCSIRO and Kerstin, which we can't reproduce. But I don't think they're show-stoppers anyway...

@LeeReid1
Copy link
Copy Markdown
Contributor Author

That sounds good to me.

@jdtournier jdtournier changed the base branch from dev to tag_3.0_RC2 August 4, 2017 10:32
@jdtournier
Copy link
Copy Markdown
Member

OK, changed base branch to tag_3.0_RC2 and updated. I'll merge once testing completes OK...

@jdtournier jdtournier merged commit eda0f33 into MRtrix3:tag_3.0_RC2 Aug 4, 2017
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.

5 participants