Skip to content

Commit

Permalink
commit for pypi upload: v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
alegiac95 committed Sep 14, 2021
1 parent 2b4e615 commit d766ec6
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 14 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include data/*
include imaging_transcriptomics/data/*
include requirements.txt
include ./**/*.yaml
2 changes: 2 additions & 0 deletions docs/chapters/01_getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ components independently and cumulatively, that can be used to tune consequent a

For more information on the use have a look at the :ref:`usage <Usage>` page. You can also have a deeper look at the
:ref:`methods <imgtrans>` and on :ref:`what to do with the results from the script <whatdo>`.

For more advanced use, or to integrate it in your python workflow, you can use the :ref:`python module <library>`.
4 changes: 2 additions & 2 deletions docs/chapters/03_installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ To install the ``imaging-transcriptomics`` Python package you must first of all

.. note::

All following steps assume that, if you have created a dedicated environment, this is currently active. If you are unsure you can check with ``which python`` from your terminal or activate your environment via the `` source activate`` (for conda managed environments) or ``source venv/bin/activate`` (for venv managed environments).
All following steps assume that, if you have created a dedicated environment, this is currently active. If you are unsure you can check with ``which python`` from your terminal or activate your environment via the ``source activate`` (for conda managed environments) or ``source venv/bin/activate`` (for venv managed environments).

Before installing the ``imaging-transcriptomics`` package we need to install a package that is not available through PyPi but from GitHub only.
This package is `pypls <https://github.com/netneurolab/pypyls>`_ and is used in the script to perform all PLS regressions.
Expand All @@ -27,7 +27,7 @@ This will install install the GitHub repository directly using pip and it will m

.. warning::

Do not install ``pyls`` directly from ``pip`` with the command ``pip install pyls`` as this is a completely different package!
Do not install pyls directly from pip with the command ``pip install pyls`` as this is a completely different package!

Once this package is installed you can install the ``imaging-transcriptomics`` package by running:

Expand Down
18 changes: 18 additions & 0 deletions docs/chapters/04_usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Optional additional parameters that can be provided are:
``--suppress`` Sets the logging level to warning and will display only eventual warning messages.


.. _library:

=======================
Usage as python library
Expand All @@ -51,4 +52,21 @@ To the library can be imported by running:
import imaging_transcriptomics as imt
Once imported the package will contain the core ``ImagingTranscriptomics`` class, along with other useful functions.

ImagingTranscriptomics Class
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The ``ImagingTranscriptomics`` class is the core class of the entire package and allows you to run the entire analysis on your data.
To start using the class the first step is to initialise it. A way to do this is:

.. code:: python
my_analysis = imt.ImagingTranscriptomics(my_data, n_components=1)
The ``my_data`` is an array that contains the data you want to analyse (e.g., the average values from the scan). This vector has to have some characteristics, mainly:
* it has to be a ``numpy.array`` with length 41, which corresponds to the number of regions in the left hemisphere of the Desikan-Killiany atlas.
* it has to contain the values you want to analyse but not the ``zscore`` of the values as this is computed automatically during the initialisation.

When initialising the class one might choose to initialise it using the ``n_components`` or the ``var`` attribute which represent the number of components to use for the regression or the variance to extract respectively.
After setting one, and only one, of the values are set, one can estiamte the other by running the ``my_analysis.pls_all_components()`` method which will compute the PLS regression with 15 components and estimate the variance explained by the user defined
6 changes: 3 additions & 3 deletions docs/chapters/07_faq.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.. _faq:

==========================
Frequently asked questions
==========================
===
FAQ
===



Expand Down
2 changes: 1 addition & 1 deletion imaging_transcriptomics/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "1.0.6"
__version__ = "1.0.0"

from . import errors
from . import bootstrap
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions imaging_transcriptomics/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def extract_average(imaging_matrix):
"""
n_regions = 41
logger.debug("Extracting average from scan.")
atlas_data = nib.load(Path(__file__).resolve().parent.parent / "data" /
atlas_data = nib.load(Path(__file__).resolve().parent / "data" /
"atlas-desikankilliany_1mm_MNI152.nii.gz").get_fdata()
data = np.zeros(n_regions)
for i in range(1, n_regions + 1):
Expand Down Expand Up @@ -89,7 +89,7 @@ def load_gene_expression():
:return: numpy array with the gene expression data.
"""
logger.debug("Loading gene_expression data.")
expression_file_path = Path(__file__).resolve().parent.parent / "data" / "gene_expression_data.csv"
expression_file_path = Path(__file__).resolve().parent / "data" / "gene_expression_data.csv"
expression_data = pd.read_csv(expression_file_path, sep=',')
my_data_x = expression_data.iloc[0:41, 2:].to_numpy()
return zscore(my_data_x, ddof=1)
Expand All @@ -102,5 +102,5 @@ def load_gene_labels():
:return: numpy array with the labels of the genes.
"""
logger.debug("Loading gene labels.")
genes_labels_path = Path(__file__).resolve().parent.parent / "data" / "gene_expression_labels.txt"
genes_labels_path = Path(__file__).resolve().parent / "data" / "gene_expression_labels.txt"
return pd.read_fwf(genes_labels_path, header=None).to_numpy()
4 changes: 2 additions & 2 deletions imaging_transcriptomics/transcriptomics.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ def permute_data(self, iterations=1_000):
self.permuted[34:, :] = sub_permuted
# Cortical
# Annotation file for the Desikan-Killiany atlas in fs5
annot_lh = Path(__file__).resolve().parent.parent / "data/fsa5_lh_aparc.annot"
annot_rh = Path(__file__).resolve().parent.parent / "data/fsa5_rh_aparc.annot"
annot_lh = Path(__file__).resolve().parent / "data/fsa5_lh_aparc.annot"
annot_rh = Path(__file__).resolve().parent / "data/fsa5_rh_aparc.annot"
# Get the parcel centroids of the Desikan-Killiany atlas
parcel_centroids, parcel_hemi = freesurfer.find_parcel_centroids(
lhannot=annot_lh,
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ scikit-learn>=0.24.2
joblib>=1.0.1
pyyaml>=5.4.1
netneurotools>=0.1.0
fpdf2>=2.0.0
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def get_requirements():
],
keywords="Image analysis, Neuroimaging, Imaging Transcriptomics, Medical Imaging, Research, Multimodal Imaging",
install_requires=get_requirements(),
packages=find_packages(),
packages=["imaging_transcriptomics"],
include_package_data=True,
package_data={"": ["*.yaml"]},
package_data={"imaging_transcriptomics": ["*.yaml", "*.nii.gz", "*.csv", "*.txt", "*.annot"]},
scripts=glob("script/imagingtranscriptomics")
)

0 comments on commit d766ec6

Please sign in to comment.