Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
robtoth committed Aug 3, 2022
2 parents 456a3ef + 8db5ce8 commit 8fc1e03
Showing 1 changed file with 87 additions and 21 deletions.
108 changes: 87 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,13 @@
# Table of Contents
- [Science](#science)
- [Overview](#overview)
- [Features](#features)
- [References](#references)
- [Code](#code)
- [Idempotence](#idempotence)
- [Documentation](#documentation)
- [Dependencies](#dependencies)
- [Installation & Usage](#installation--usage)
- [Executive Summary for Experts](#executive-summary-for-experts)
- [Docker](#docker)
- [Docker Setup](#docker-setup)
- [collageradiomics-examples Docker Image](#collageradiomics-examples-docker-image)
- [collageradiomics-pip Docker Image](#collageradiomics-pip-docker-image)
- [Pip](#pip)
- [Python Usage](#python-usage)
- [Basic Example](#basic-example)
- [Real Data](#real-data)
- [Other Platforms](#other-platforms)
- [Contact](#contact)
- [Installation & Setup](#installation--setup)
- [Pip Usage](#pip-usage)
- [Docker Notebooks](#docker-notebooks)
- [Docker Sandbox](#docker-sandbox)
- [Python Usage](#python-usage)

# Science
## Overview
Expand Down Expand Up @@ -63,21 +52,21 @@ If you make use of this implementation, please cite the following paper:
# Code
_[Back to **Table of Contents**](#table-of-contents)_

## Idempotence
We made the collage object idempotent Our **CoLlAGe** module includes parameter tuning information in the output. It contains the image(s) and mask(s), and the settings applied upon them. This allows multiple fully reproducible runs without having to remember or find the original parameters.

## Documentation
Documentation can be found at
http://collageradiomics.rtfd.io/

## Dependencies:
We depend on the following libraries:
- `matplotlib`
- `numpy`
- `scikit-learn`
- `scikit-build`
- `sklearn`
- `mahotas`
- `scipy`

# Installation & Usage
# Installation & Setup
_[Back to **Table of Contents**](#table-of-contents)_

## Pip Usage
Expand All @@ -100,7 +89,8 @@ sudo apt -y install build-essential gcc gfortran python-dev libopenblas-dev libl
pip3 install -r requirements.txt

# run test script
python3 collageradiomics/modules/test_script.py
cd modules
python3 test_script.py
```

## Docker Notebooks
Expand Down Expand Up @@ -158,3 +148,79 @@ Type "help", "copyright", "credits" or "license" for more information.
>>> collageradiomics.__name__
'collageradiomics'
```

# Python Usage
_[Back to **Table of Contents**](#table-of-contents)_
```python

##################################################
# imports
import collageradiomics
import pydicom
import logging
from pydicom.pixel_data_handlers.util import apply_modality_lut, apply_voi_lut
from skimage.exposure import equalize_hist
import numpy as np
from sklearn.preprocessing import minmax_scale
from random import randint
##################################################


##################################################
# logging
level = logging.INFO
logging.basicConfig(level=level)
logger = logging.getLogger()
logger.setLevel(level)
logger.info('Hello, world.')
##################################################


##################################################
# loading data
local_dcm_file = 'test.dcm'
instance = pydicom.dcmread(local_dcm_file)
slice_instance_uid = instance.SOPInstanceUID
logger.debug(f'slice_instance_uid = {slice_instance_uid}')
##################################################


##################################################
# preprocessing
logger.info('Correcting image...')
np_array = instance.pixel_array
corrected = apply_modality_lut(np_array, instance)
corrected = apply_voi_lut(corrected, instance)
scaled_array = equalize_hist(corrected)
logger.debug(f'np.histogram(scaled_array) = {np.histogram(scaled_array)}')
logger.info('done.')
##################################################


##################################################
# rectangular selection
width = 50
height = 50
min_row = randint(30,300)
max_row = min_row + height
min_col = randint(30,300)
max_col = min_col + width

original_shape = np_array.shape
logger.debug(f'original_shape = {original_shape}')
logger.info('Calculating collage features...')
mask_array = np.zeros(original_shape, dtype='int')
mask_array[min_row:max_row, min_col:max_col] = 1
##################################################


##################################################
# run collage
textures = collageradiomics.Collage(scaled_array, mask_array).execute()

logger.debug(f'textures.shape = {textures.shape}')
logger.debug(f'textures.dtype = {textures.dtype}')
logger.debug(f'np.histogram(textures.flatten()) = {np.histogram(textures.flatten(), range=(np.nanmin(textures), np.nanmax(textures)))}')
##################################################

```

0 comments on commit 8fc1e03

Please sign in to comment.