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

New function to create violin plots from sct_pipeline results #1759

Merged
merged 3 commits into from
May 21, 2018

Conversation

jcohenadad
Copy link
Member

Description of the Change

Implements a new function to generate visual results from sct_pipeline.

Example usage:

sct_pipeline_makefig -i branch-to-test.pickle master.pickle -label branch-to-test master

Generated figure:
violin_plot

Future improvements:

  • Implement metadata inside sct_pipeline results and use them in this function (notably to get rid of the flag label)

Copy link
Contributor

@zougloub zougloub left a comment

Choose a reason for hiding this comment

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

Some feedback, to be considered or not

def get_parser():
parser = argparse.ArgumentParser(
description='Generate figure from the output of sct_pipeline.')
parser.add_argument("-i",
Copy link
Contributor

Choose a reason for hiding this comment

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

When using argparse for new code, suggest to use short/long arguments:

 "-i", "--input",
"-l", "--label",
"-v", "--verbose",

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed in 9d77c82

sct.start_stream_logger()

# fs = 10 # font size
nb_plots = args.i.__len__()
Copy link
Contributor

Choose a reason for hiding this comment

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

This way, the long argument name will be used as default attribute name (args.input if above was used).

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed in 9d77c82

list_data = []
text_results = [] # numerical results to display inside the figure
for fname_pickle in args.i:
df = pickle.load(open(fname_pickle, "rb"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Could be changed to io.open() (more explanatory IMO, but it's a question of taste/habits)

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed in 9d77c82

#
# Generate figure from the output of sct_pipeline.
#
# Copyright (c) 2013 Polytechnique Montreal <www.neuro.polymtl.ca>
Copy link
Contributor

Choose a reason for hiding this comment

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

2018

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed in 9d77c82


if __name__ == '__main__':
parser = get_parser()
arguments = parser.parse_args()
Copy link
Contributor

Choose a reason for hiding this comment

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

Although you can invoke the program with -i file_1 -label A -i file_2 -label B you will invariably have users who end up doing -i file_1 file_2 -label A B and end up with -i file_1 file_2 -label A.

if len(arguments.i) != len(arguments.label):
    raise RuntimeError("Mismatch between # of files and labels")

Perhaps the labels should be the file names, if not provided.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed in 9d77c82

@jcohenadad jcohenadad merged commit d40444e into master May 21, 2018
@jcohenadad jcohenadad deleted the jca_pipelineViolin branch May 21, 2018 11:19
@jcohenadad jcohenadad added this to the 3.2.0 milestone May 29, 2018
@jcohenadad jcohenadad added feature category: new functionality sct_pipeline context: labels May 29, 2018
jcohenadad added a commit that referenced this pull request Dec 18, 2019
* New function to create violin plots from sct_pipeline results

* Various fixes and improvements


Former-commit-id: d40444e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature category: new functionality sct_pipeline context:
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants