Methods

Reading and accessing data

Data

All methods except generate_3d_image are methods applied to the Data object.

Data(path, id_type='numeric', id_list=None)

Attributes:

  • path: str
    • Path to MRICloud data text file
  • id_type: str, {'numeric', 'filename', 'custom'}, default = 'numeric'
    • Type of subject ID formatting
  • id_list: list, default = None
    • List of custom subject IDs
  • df: DataFrame
    • DataFrame generated from path

get_data

Retrieve DataFrame of a given data object.

get_data()

Parameters:

  • None

Returns: DataFrame


get_id

Retrieve list of unique subject IDs.

get_id()

Parameters:

  • None

Returns: Series


Manipulating data

rename_subject

Rename a specific subject ID.

rename_subject(old, new)

Parameters:

  • old: str
    • Old subject name to be replaced
  • new: str
    • New subject name

Returns: DataFrame

long_to_wide

Convert default long form data to a wide format.

long_to_wide()

Parameters:

  • None

Returns: DataFrame


Visualization

generate_sunburst

Generate a Plotly Express sunburst Figure model.

generate_sunburst(type, id, base_level=5)

Parameters:

  • type: int, {1, 2}
    • Type of hierarchical view
  • id: str
    • Subject ID
  • base_level: int, {1, 2, 3, 4, 5}, default = 5
    • Lowest hierarchical level to include

Returns: Figure


generate_treemap

Generate a Plotly Express treemap Figure model.

generate_treemap(type, id, base_level=5)

Parameters:

  • type: int, {1, 2}
    • Type of hierarchical view
  • id: str
    • Subject ID
  • base_level: int, {1, 2, 3, 4, 5}, default = 5
    • Lowest hierarchical level to include

Returns: Figure


generate_icicle

Generate a Plotly Express icicle Figure model.

generate_icicle(type, id, base_level=5)

Parameters:

  • type: int, {1, 2}
    • Type of hierarchical view
  • id: str
    • Subject ID
  • base_level: int, {1, 2, 3, 4, 5}, default = 5
    • Lowest hierarchical level to include

Returns: Figure


generate_bar

Generates a Plotly Express bar graph Figure.

generate_bar(type, level, id, x='ID', y='Prop', log_y=False)

Parameters:

  • type: int, {1, 2}
    • Type of hierarchical view
  • level: int, {1, 2, 3, 4, 5}
    • Hierarchical level of interest
  • id: list, default = None
    • Subjects of interest
  • x: str, {'ID', 'Object'}, default = 'ID'
    • Independent variable
  • y: str, {'Prop', 'Volume'}, default = 'Prop'
    • Dependent variable
  • log_y: bool, default = False
    • Logarithm of dependent variable

Returns: Figure


generate_mean_diff

Generate a Plotly Express mean difference plot Figure.

generate_mean_diff(type, level, color='ID', id=None)

Parameters:

  • type: int, {1, 2}
    • Type of hierarchical view
  • level: int, {1, 2, 3, 4, 5}
    • Hierarchical level of interest
  • color: str, {'ID', 'Object'}, default = 'ID'
    • Variable to organize data by color
  • id: list, default = None
    • Subjects of interest

Returns: Figure


generate_corr_matrix

Generate a Plotly Express heatmap Figure of a correlation matrix.

generate_corr_matrix(type, level, id=None)

Parameters:

  • type: int, {1, 2}
    • Type of hierarchical view
  • level: int, {1, 2, 3, 4, 5}
    • Hierarchical level of interest
  • id: list, default = None
    • Subjects of interest

Returns: Figure


Modeling and covariate analysis

append_covariate_data

Append covariate dataset to data object.

append_covariate_data(path, icv=False, tbv=False)

Parameters:

  • path: str
    • Path to covariate dataset file
  • icv: bool, default = False
    • Append intracranial volume to covariate dataset
  • tbv: bool, default = False
    • Append total brain volume to covariate dataset

Returns: DataFrame


normalize_covariate_data

Normalize region data in covariate dataset by ICV, TBV, or ICV + TBV.

normalize_covariate_data(covariate_dataset, normalizing_factor)

Parameters:

  • covariate_dataset: DataFrame
    • Covariate dataset to be normalized
  • normalizing_factor: str, {'icv, tbv, icv_tbv'}
    • Variable to normalize region volumes by

Returns: DataFrame


OLS

Run statsmodels Ordinary Least Squares regression on data object.

OLS(covariate_dataset, covariates, outcome, log=False, residual_plot=False)

Parameters:

  • covariate_dataset: DataFrame
    • Dataset containing the covariates and outcome
  • covariates: list
    • Covariates to include in analysis (x, independent covariates)
  • outcome: str
    • Outcome of interest (y, dependent covariate)
  • log: bool, default = False
    • Logaritm of covariates
  • residual_plot: bool, default = False
    • Return a residual plot of analysis results as Plotly Figure

Returns: RegressionResultsWrapper.summary(), Figure


Logit

Run statsmodels Logit regression on data object.

Logit(covariate_dataset, covariates, outcome, log=False, roc_plot=False)

Parameters:

  • covariate_dataset: DataFrame
    • Dataset containing the covariates and outcome
  • covariates: list
    • Covariates to include in analysis (x, independent covariates)
  • outcome: str
    • Outcome of interest (y, dependent covariate)
  • log: bool, default = False
    • Logaritm of covariates
  • roc_plot: bool, default = False
    • Return a residual plot of analysis results as Plotly Figure

Returns: RegressionResultsWrapper.summary(), Figure


Imaging

Generates a subplot or single image (if 'nrows' and 'ncols' is 1) of region-specific brain images on a template brain

generate_3d_image

generate_3d_image(img_path, regions, view, nrows, ncols, slice_n=0)

Parameters:

  • img_path: str
  • regions: list
  • view: int, {0 (horizontal), 1 (sagittal), 2 (coronal)}
  • nrows: int, {1, 2, 3, 4, 5, 6, 7}
  • ncols: int, {1, 2, 3, 4, 5, 6, 7}
  • slice_n: int, default = 0