HedTagSummary

class HedTagSummary(sum_op)[source]

Manager of the HED tag summaries.

Methods

HedTagSummary.__init__(sum_op)

Constructor for HED tag summary manager.

HedTagSummary.dump_summary(filename, summary)

HedTagSummary.get_details_dict(tag_counts)

Return the summary-specific information in a dictionary.

HedTagSummary.get_individual(summary_details)

Return a dictionary of the individual file summaries.

HedTagSummary.get_summary([individual_summaries])

Return a summary dictionary with the information.

HedTagSummary.get_summary_details([...])

Return a dictionary with the details for individual files and the overall dataset.

HedTagSummary.get_text_summary([...])

Return a complete text summary by assembling the individual pieces.

HedTagSummary.get_text_summary_details([...])

Return a text summary of the information represented by this summary.

HedTagSummary.merge_all_info()

Create a HedTagCounts containing the overall dataset HED tag summary.

HedTagSummary.save(save_dir[, file_formats, ...])

Save the summaries using the format indicated.

HedTagSummary.save_visualizations(save_dir)

Save the summary visualizations if any.

HedTagSummary.summary_to_dict(specifics[, ...])

Convert a HedTagSummary json specifics dict into the word cloud input format.

HedTagSummary.update_summary(new_info)

Update the summary for a given tabular input file.

Attributes

HedTagSummary.DISPLAY_INDENT

HedTagSummary.INDIVIDUAL_SUMMARIES_PATH

HedTagSummary.__init__(sum_op)[source]

Constructor for HED tag summary manager.

Parameters:

sum_op (SummarizeHedTagsOp) – Operation associated with this summary.

static HedTagSummary.dump_summary(filename, summary)
HedTagSummary.get_details_dict(tag_counts)[source]

Return the summary-specific information in a dictionary.

Parameters:

tag_counts (HedTagCounts) – Contains the counts of tags in the dataset.

Returns:

dictionary with the summary results.

Return type:

dict

HedTagSummary.get_individual(summary_details, separately=True)

Return a dictionary of the individual file summaries.

Parameters:
  • summary_details (dict) – Dictionary of the individual file summaries.

  • separately (bool) – If True (the default), each individual summary has a header for separate output.

HedTagSummary.get_summary(individual_summaries='separate')

Return a summary dictionary with the information.

Parameters:

individual_summaries (str) – “separate”, “consolidated”, or “none”

Returns:

dict - dictionary with “Dataset” and “Individual files” keys.

Notes: The individual_summaries value is processed as follows:
  • “separate” individual summaries are to be in separate files.

  • “consolidated” means that the individual summaries are in same file as overall summary.

  • “none” means that only the overall summary is produced.

HedTagSummary.get_summary_details(include_individual=True)

Return a dictionary with the details for individual files and the overall dataset.

Parameters:

include_individual (bool) – If True, summaries for individual files are included.

Returns:

dict - a dictionary with ‘Dataset’ and ‘Individual files’ keys.

Notes

  • The ‘Dataset’ value is either a string or a dictionary with the overall summary.

  • The ‘Individual files’ value is dictionary whose keys are file names and values are

    their corresponding summaries.

Users are expected to provide merge_all_info and get_details_dict functions to support this.

HedTagSummary.get_text_summary(individual_summaries='separate')

Return a complete text summary by assembling the individual pieces.

Parameters:

individual_summaries (str) – One of the values “separate”, “consolidated”, or “none”.

Returns:

Complete text summary.

Return type:

str

Notes: The options are:
  • “none”: Just has “Dataset” key.

  • “consolidated” Has “Dataset” and “Individual files” keys with the values of each is a string.

  • “separate” Has “Dataset” and “Individual files” keys. The values of “Individual files” is a dict.

HedTagSummary.get_text_summary_details(include_individual=True)

Return a text summary of the information represented by this summary.

Parameters:

include_individual (bool) – If True (the default), individual summaries are in “Individual files”.

HedTagSummary.merge_all_info()[source]

Create a HedTagCounts containing the overall dataset HED tag summary.

Returns:

The overall dataset summary object for HED tag counts.

Return type:

HedTagCounts

HedTagSummary.save(save_dir, file_formats=['.txt'], individual_summaries='separate', task_name='')

Save the summaries using the format indicated.

Parameters:
  • save_dir (str) – Name of the directory to save the summaries in.

  • file_formats (list) – List of file formats to use for saving.

  • individual_summaries (str) – Save one file or multiple files based on setting.

  • task_name (str) – If this summary corresponds to files from a task, the task_name is used in filename.

HedTagSummary.save_visualizations(save_dir, file_formats=['.svg'], individual_summaries='separate', task_name='')[source]

Save the summary visualizations if any.

Parameters:
  • save_dir (str) – Path to directory in which visualizations should be saved.

  • file_formats (list) – List of file formats to use in saving.

  • individual_summaries (str) – One of “consolidated”, “separate”, or “none” indicating what to save.

  • task_name (str) – Name of task if segregated by task.

static HedTagSummary.summary_to_dict(specifics, transform=<ufunc 'log10'>, scale_adjustment=7)[source]

Convert a HedTagSummary json specifics dict into the word cloud input format.

Parameters:
  • specifics (dict) – Dictionary with keys “Main tags” and “Other tags”.

  • transform (func) – The function to transform the number of found tags. Default log10

  • scale_adjustment (int) – Value added after transform.

Returns:

a dict of the words and their occurrence count.

Return type:

word_dict(dict)

Raises:

KeyError – A malformed dictionary was passed.

HedTagSummary.update_summary(new_info)[source]

Update the summary for a given tabular input file.

Parameters:

new_info (dict) – A dictionary with the parameters needed to update a summary.

Notes

  • The summary needs a “name” str, a “schema”, a “df, and a “Sidecar”.

HedTagSummary.DISPLAY_INDENT = '   '
HedTagSummary.INDIVIDUAL_SUMMARIES_PATH = 'individual_summaries'