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

mrpeek: added no text mode, modified boolean cmd line options #40

Merged
merged 9 commits into from
Nov 17, 2020

Conversation

maxpietsch
Copy link
Member

Added an option to remove text output in interactive or non-interactive mode. In non-interactive mode, this allows writing a sixel image to file via

mrpeek im.mif -text no -inter no > im.sixel
mrpeek im.mif -text no -inter no -image no -cross -1 -1 -plot 0 > plot.sixel

which can then be displayed via cat on supported terminals or converted to png using sixel2png.

cmd/mrpeek.cpp Outdated

if (orthoview) {
if (interactive and orthoview and show_text) {
Copy link
Member

Choose a reason for hiding this comment

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

Been writing a lot of python lately...?

Copy link
Member Author

Choose a reason for hiding this comment

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

%:include <iostream>
 
struct X
<%
    compl X() <%%> // destructor
    X() <%%>
    X(const X bitand) = delete; // copy constructor
 
    bool operator not_eq(const X bitand other)
    <%
       return this not_eq bitand other;
    %>
%>;
 
int main(int argc, char* argv<::>) 
<%
    // lambda with reference-capture:
    auto say = <:bitand:>(const char* name)
    <%
        std::cout << "I like " << name << '\n';
    %>;
 
    if (argc > 1 and argv<:1:> not_eq nullptr) <%
        say(argv<:1:>);
    %>
    else <%
        say("Python");
    %>
%>

Copy link
Member

Choose a reason for hiding this comment

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

Wow, I had no idea there was such a thing as the alternative operators... Guess you learn something new every day!

@jdtournier
Copy link
Member

Looks good, other than some slightly iffy syntax in places... ;)

Couple of thoughts, not necessarily related to this PR as such:

  • I reckon it would be nice to also default to non-interactive mode if stdout is not pointing to a TTY. We could use the same approach we already use on MRtrix core to disable vt100 codes and switch the progressbar behaviour when redirected to file.

  • every time I have to use the -interactive option, it bothers me that we have to specify 0 or no when clearly the default mode of action is interactive. I'd prefer to provide a single -batch option with no additional arguments.

    Similar with the -orthoview option. I think I'd rather reinterpret the -axis option as requesting non-orthoview mode with the projection requested. Could also replace that -axis option with (or just add) more explicit -axial, -sagittal and -coronal options, again with the understanding that this disables orthoview.

- removed axis and orthoview options.
- interactive y/n --> batch
- added sagittal, coronal, axial options which deactivate orthoview
- image y/n and text y/n --> noimage notext
@maxpietsch
Copy link
Member Author

Simplified the options as suggested and changed -image y/n and -text y/n to -noimage and -notext in e9dcfda. The TTY detection is not implemented yet.

OPTIONS

  -batch
     disables interactive mode

  -sagittal
     view sagittal projection only. Default: orthoview

  -coronal
     view coronal projection only. Default: orthoview

  -axial
     view axial projection only. Default: orthoview

  -slice number
     select slice to display

  -plot number
     specify plot dimension: 0: L/R (sagittal); 1: A/P (coronal); 2 I/S
     (axial); 3 volumes...

  -intensity_range min max
     specify intensity range of the data. The image intensity will be scaled
     between the specified minimum and maximum intensity values. By default,
     percentile scaling is used.

  -percentile_range min max
     specify intensity range of the data. The image intensity will be scaled
     between the specified minimum and maximum percentile values. Defaults are:
     0.2 - 99.8

  -colourmap name
     the colourmap to apply; choices are:
     gray,hot,cool,jet,inferno,viridis,pet. Default is gray.

  -crosshairs x y
     draw crosshairs at specified position. Set to negative position to hide.

  -levels number
     number of intensity levels in the colourmap. Default is 32.

  -zoom factor
     scale the image size by the supplied factor

  -notext
     omit text output to show only the sixel image

  -noimage
     do not render the main image

@maxpietsch maxpietsch changed the title mrpeek: added no text mode mrpeek: added no text mode, modified boolean cmd line options Oct 29, 2020
@jdtournier
Copy link
Member

5f78ff7 should address most of the issues in #39 - apart from the -scanner option.

@maxpietsch
Copy link
Member Author

maxpietsch commented Oct 30, 2020

I made the focus explicitly integer-valued otherwise floating-point values would just be truncated. Looks all good to me.

@jdtournier
Copy link
Member

Nope, has to be floating point if you want to be able to skip indices, as per the example in the command line usage. An empty entry returns a NaN for a sequence of floats, but that's not supported for a sequence of ints.

@maxpietsch
Copy link
Member Author

Ok, but I'd round instead of truncate: c3fddd2

@jdtournier
Copy link
Member

👍

@jdtournier jdtournier merged commit 5b6b335 into master Nov 17, 2020
@jdtournier jdtournier deleted the notext branch November 17, 2020 15:27
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.

2 participants