Code Monkey home page Code Monkey logo

dcbia-ortholab / mfsda_python Goto Github PK

View Code? Open in Web Editor NEW

This project forked from big-s2/mfsda_python

3.0 6.0 10.0 14.92 MB

Multivariate Functional Shape Data Analysis in Python (MFSDA_Python) is a Python based package for statistical shape analysis. A multivariate varying coefficient model is introduced to build the association between the multivariate shape measurements and demographic information and other clinical, biological variables. Statistical inference, i.e., hypothesis testing, is also included in this package, which can be used in investigating whether some covariates of interest are significantly associated with the shape information. The hypothesis testing results are further used in clustering based analysis, i.e., significant suregion detection. This MFSDA package is developed by Chao Huang and Hongtu Zhu from the BIG-S2 lab.

License: Apache License 2.0

Python 86.66% CMake 13.02% Dockerfile 0.31%
3d-slicer-extension

mfsda_python's Introduction

MFSDA: Multivariate Functional Shape Data Analysis

MFSDA_Python is a Python based package for statistical shape analysis.

A multivariate varying coefficient model is introduced to build the association between the multivariate shape measurements and demographic information and other clinical variables.

Statistical inference, i.e., hypothesis testing, is also included in this package, which can be used in investigating whether some covariates of interest are significantly associated with the shape information.

The hypothesis testing results are further used in clustering based analysis, i.e., significant suregion detection.

Modules

Loadable module

MFSDA UI

The project loadable module allowing MFSDA to invoke the command line module MFSDA_run and MFSDA_createShapes. More details below.

CLI modules

CLI Name Description
MFSDA_selectVariablesPCA Variable selection using Correlation with Principal Components.
MFSDA_run Main script to run the Multivariate Funcional Shape Data Analysis
MFSDA_createShapes After completion, add the pvalues/efit to a shape for visualization

MFSDA_selectVariablesPCA.py

Variable selection UI

Helper script for variable selection using pearson correlations with the principal components (PCA). Runs PCA in the dataset and selects the first 'n' first principal components. A correlation analysis is done with each variable in the dataset and the principal components. This analysis will give you an idea of how correlated each variable is to the first 'n' principal components, in other words, how much does each variable contribute to a principal components. Ideally, when running MFSDA, you should select variables that are not correlated between each other or select variables that contribute to different principal components.

Required inputs
csv

Input table with header row (covariate names). One row per subject.

ouput

Output directory. It will generate a pdf file with the plots and a set of json and csv files with outputs of the analysis, i.e., the percentage of contribution for each variable to the principal component.

MFSDA/MFSDA_run.py

This is the main script of the application to run the Multivariate Functional Shape Data Analysis.

Required inputs

Run the script MFSDA_run.py with flag '-h' or '--help' for more information.

shapeData

This is a text file that contains the vtk filenames to the shapes/3D models and the corresponding covariates for each shape. The fields must be separated by ','. The first column must be the filename to the shape.

coordData

This is the template that is used to align the shapes in a common space or spherical mapping. Please check SPHARM-PDM

outputDir

Output directory

MFSDA/MFSDA_createShapes.py

Once MFSDA is completed, you may add the resulting pvalues/efit coefficients to a shape from your population.

Required inputs

Run the script MFSDA_createShapes.py with flag '-h' or '--help' for more information.

shape

Input vtk shape/3D model.

pvalues

Resulting pvalues json file from MFSDA_run.

efit

Resulting efit json file from MFSDA_run.

covariates

Covariate names, ex. '--covariates age gender group var1'. These names are used to add arrays to the .vtk file. You can later visualize them in '3DSlicer' or 'ShapePopulationViewer'

output

Output vtk file.

License

It is covered by the Apache License, Version 2.0:

http://www.apache.org/licenses/LICENSE-2.0

The license file was added at revision 3ccc5e9 on 2020-12-10, but you may consider that the license applies to all prior revisions as well.

History

This project was initially developed in early August 2017 by Chao Huang and Hongtu Zhu from the BIG-S2 lab at the University of North Carolina at Chapel Hill School of Medicine.

Then, between November 2017 and June 2018, Juan Carlos Prieto from the School of Dentistry at the University Of Michigan contributed the script for generating shapes with pvalue maps, and Loic Michoud, in the context of internship, contributed the MFSDA Slicer loadable module along with the initial infrastructure to support distribution as a Slicer extension (developed in an independent branch available here).

Then, in November 2018, in the context of an internship at NIRAL (Neuro Image Research and Analysis Laboratories) in the Department of Psychiatry at the University of North Carolina at Chapel Hill School of Medicine, Mateo Lopez further improved the Slicer loadable module by improving the user interface, re-organizing files and renaming the loadable module from ShapeDistanceAnalyzer to MFSDA.

Then, in 2019, Juan Carlos Prieto from NIRAL added the script MFSDA_selectVariablesPCA.py for performing the PCA of a set of variables and doing a correlation analysis with the N principal components.

Later, in 2019-2020, Beatriz Paniagua, Jared Vicory, Jean-Christophe Fillion-Robin and Sam Horvath from Kitware Inc. worked on improving the user interface and robustness, transitioning to Python 3.x and revamping the build-system to support distribution as a Slicer extension.

mfsda_python's People

Contributors

allemangd avatar bpaniagua avatar chaohstat avatar jcfr avatar juanprietob avatar lopezmt avatar mahmoudmostapha avatar sjh26 avatar vicory avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

mfsda_python's Issues

Python requirements need to be updated for latest Slicer python version

Slicer recently upgraded from Python 3.6.7 to Python 3.9.10 in Slicer/Slicer@34e48e8. There are now observed build errors of the MFSDA Slicer extension as seen at https://slicer.cdash.org/viewBuildError.php?buildid=2581568. This is because the python requirements file in the repo is including hashes that are only for Python 3.6 wheels. These need to be updated for Python 3.9 wheels which also means the actual version of packages here will need to be updated as some older versions simply don't have Python 3.9 wheels because that version was released before Python 3.9 was even released.

file(WRITE ${requirements_file} [===[
# Hashes correspond to the following packages:
# - python_dateutil-2.8.1-py2.py3-none-any.whl
python-dateutil==2.8.1 --hash=sha256:75bb3f31ea686f1197762692a9ee6a7550b59fc6ca3a1f4b5d7e32fb98e2da2a
# Hashes correspond to the following packages:
# - pytz-2020.1-py2.py3-none-any.whl
pytz==2020.1 --hash=sha256:a494d53b6d39c3c6e44c3bec237336e14305e4f29bbf800b599253057fbb79ed
# Hashes correspond to the following packages:
# - pandas-1.0.5-cp36-cp36m-win_amd64.whl
# - pandas-1.0.5-cp36-cp36m-macosx_10_9_x86_64.whl
# - pandas-1.0.5-cp36-cp36m-manylinux1_x86_64.whl
pandas==1.0.5 --hash=sha256:35b670b0abcfed7cad76f2834041dcf7ae47fd9b22b63622d67cdc933d79f453 \
--hash=sha256:faa42a78d1350b02a7d2f0dbe3c80791cf785663d6997891549d0f86dc49125e \
--hash=sha256:8778a5cc5a8437a561e3276b85367412e10ae9fff07db1eed986e427d9a674f8
# Hashes correspond to the following packages:
# - patsy-0.5.1-py2.py3-none-any.whl
patsy==0.5.1 --hash=sha256:5465be1c0e670c3a965355ec09e9a502bf2c4cbe4875e8528b0221190a8a5d40
# Hashes correspond to the following packages:
# - statsmodels-0.11.1-cp36-none-win_amd64.whl
# - statsmodels-0.11.1-cp36-cp36m-macosx_10_13_x86_64.whl
# - statsmodels-0.11.1-cp36-cp36m-manylinux1_x86_64.whl
statsmodels==0.11.1 --hash=sha256:49aa8ffbe0b0e2e86afa58dec6bd5c483898e9b8223d8a7d13b69b5ad144b674 \
--hash=sha256:5e7afc596164c1c7464ba3943721a9668aa0ce07853ce9881ac49d3a043784dd \
--hash=sha256:9efd2e27c08077330cecdbfb589cf84d735abface94e9a6387282a6a7c91362d
]===])

Publish tutorial

There is a tutorial powerpoint dangling in #10 from Mahmoud Mostapha, is there a DCBIA google drive where I could upload it as Google slides ?

Or since it corresponds to a tutorial written for SlicerSALT, is there already a public URL for it ?

Motivation: This tutorial would be referenced in the README and help user understand how to use the extension.

Challenge: Because of naming different between the loadable module in SlicerSALT and the default name in the extension, user will likely be confused by reading the tutorial. See #16

image

MFSDA fails with one covariate

Current code makes assumption that the covariates read from the file has 2d shape (i.e. rows and columns) while the numpy reader will collapse the second dimension if there is only 1 column.

Code can fail for singular matrices

I've occasionally run into the code failing when trying to invert a singular matrix. Code could check for this error and use a pseudo-inverse instead.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.