Giter VIP home page Giter VIP logo

ccipd / mrqy Goto Github PK

View Code? Open in Web Editor NEW
88.0 5.0 27.0 234.81 MB

MRQy is a quality assurance and checking tool for quantitative assessment of magnetic resonance imaging (MRI) data.

License: BSD 3-Clause Clear License

Python 32.02% JavaScript 59.68% HTML 4.76% Dockerfile 0.11% CSS 3.42%
mri quality-control quality-assurance quality-metrics imaging machine-learning medical-imaging medical-image-processing medical-physics python

mrqy's Introduction

Picture1

Front-end View

gbm_mrqy

Backend View

gbm_mrqy

Table of Contents

Description

This tool takes MRI datasets in the file formats (.dcm, .nii, .nii.gz or .mha) as the input.
Two Python scripts (QC.py and QCF.py) are used to generate several tags and noise/information measurements for quality assessment. These scripts save the calculated measures in a .tsv file as well as generate .png thumbnails for all images in a subject volume. These are then fed to .js scripts to create the user interface (index.html) output. A schematic illustrating the framework of the tool is as follows.

Picture1

Prerequisites

The current version of the tool has been tested on the Python 3.6+
You must have pipenv installed on your environment to run MRQy locally. It will pull all the dependencies listed in the diagram.

Picture7

You can also likely install the python requirements using something like:

pip3 install -r requirements.txt

Running

For local development, test that the code is functional

MRQy % pipenv shell
(mrqy) MRQy% pipenv install .
(mrqy) MRQy% python -m mrqy.QC --help

The output should be

usage: QC.py [-h] output_folder_name [inputdir [inputdir ...]]

positional arguments:
  output_folder_name  the subfolder name on the
                      '...\UserInterface\Data\output_folder_name' directory.
  inputdir            input foldername consists of *.mha (*.nii or *.dcm)
                      files. For example: 'E:\Data\Rectal\input_data_folder'

optional arguments:
  -h, --help          show this help message and exit
  

Standard usage is to run QC.py output_folder_name “input directory” i.e.

python QC.py output_folder_name "E:\Data\Rectal\RectalCancer_Multisite\input_data_folder"

There is no need to make a subfolder in the Data directory, just specify its name in the command as in the above code.
Every action will be printed in the output console.
The thumbnail images in the format of .png will be saved in "...\UserInterface\Data\output_folder_name" with its original filename as the subfolder name. Afterward, double click "index.html" (on e.g. "D:\Downloads\MRQy-master\UserInterface") to open front-end user interface, and select the respective results.tsv file from the correct location e.g. "D:\Downloads\MRQy-master\UserInterface\Data\output_folder_name" directory.

Contribution guidelines

Testing

MRQy % pipenv shell
(mrqy) MRQy% pipenv install .
(mrqy) MRQY% pipenv run -m pytest tests/

Building on Travis

The recommended path is to follow the Forking Workflow. Create a Travis CI build for your github fork to validate your fork before pushing a merge request to master.

Basic Information

Measurements

The measures of the MRQy tool are listed in the following table.

Picture1

User Interface

The following figures show the user interface of the tool (index.html).

C1 C2 C3

Feedback and usage

Please report and issues, bugfixes, ideas for enhancements via the "Issues" tab.

Detailed usage instructions and an example of using MRQy to analyze TCIA datasets are in the Wiki.

You can cite this in any associated publication as:
Sadri, AR, Janowczyk, A, Zou, R, Verma, R, Beig, N, Antunes, J, Madabhushi, A, Tiwari, P, Viswanath, SE, "Technical Note: MRQy — An open-source tool for quality control of MR imaging data", Med. Phys., 2020, 47: 6029-6038. https://doi.org/10.1002/mp.14593

ArXiv: https://arxiv.org/abs/2004.04871

If you do use the tool in your own work, please drop us a line to let us know.

mrqy's People

Contributors

amir-reza-sadri avatar dependabot[bot] avatar mohsenhariri avatar nathanhillyer avatar raghuiyer avatar satishev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mrqy's Issues

4D datasets

Hi Amir,

Can the tool also deal with 4D datasets (e.g. fMRI)? I find that matplotlib returns an error ('Third dimension must be 3 or 4') when the input is 4D.

Am I missing something here?

Thanks!

Lung MRI project

Hello

I am trying to apply your tool for the Lung MR imaging.
I has been looking for a tool to get some quantitative values such as SNR, CNR from the before and after denoising to Lung MR images.
And finally, your MRQy gives me what I've been looking for. Yes, it works very successfully. ( thank you again for your great work!!)
But I think I'd better to check (because it's Lung MR , zero TE image) whether it selects lung correctly.
I just want to see overlay mask to see what's selected for foreground iamges because...the Lung itself has lower signal compare to the other surrounding muscle and fat.
Please check the Lung MR images if you want, "Comparison of lung imaging using three-dimensional ultrashort echo time and zero echo time sequences: preliminary study"

At this point, I wonder if there is any way to extract the"selected foreground and background boundary, overlay mask" ,
Also, can I extract "MEAN of background" with MEAN of foreground , together ?
Those two information will be important to check whether it successfully worked to the Lung MR or not.

Any comment and advice would be very appreciated.
best regards
Moonjung

File exists error when saving the thumbnails

Hi, I'm testing this tool in a folder structure organized as follows:

.
├── ID1
│   ├── CT1.nii
│   └── FLAIR.nii
└── ID2
    ├── CT1.nii
    └── FLAIR.nii

And I'm getting this error:

Traceback (most recent call last):
  File "QC.py", line 359, in <module>
    saveThumbnails_nondicom(v,fname_outdir)
  File "QC.py", line 181, in saveThumbnails_nondicom
    os.makedirs(output + os.sep + v[1])
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/os.py", line 223, in makedirs
    mkdir(name, mode)
FileExistsError: [Errno 17] File exists: '/Users/censored/mrqy/MRQy/src/mrqy/UserInterface/Data/Jun24test/CT1'

I believe the issue is that when saving the thumbnails, these are stored in a single, flat folder that doesn't follow the original tree structure, so the program finds that the "CT1" folder already exists:

.
├── CT1
│   ├── CT1(1).png
│   ├── CT1(10).png
│   ├── CT1(11).png
│   ├── CT1(12).png
│   ├── CT1(13).png
│   ├── CT1(14).png
│   ├── CT1(15).png
│   ├── CT1(16).png
│   ├── CT1(17).png
│   ├── CT1(18).png
│   ├── CT1(19).png
│   ├── CT1(2).png
│   ├── CT1(20).png
│   ├── CT1(21).png
│   ├── CT1(22).png
│   ├── CT1(23).png
│   ├── CT1(24).png
│   ├── CT1(25).png
│   ├── CT1(26).png
│   ├── CT1(27).png
│   ├── CT1(28).png
│   ├── CT1(29).png
│   ├── CT1(3).png
│   ├── CT1(4).png
│   ├── CT1(5).png
│   ├── CT1(6).png
│   ├── CT1(7).png
│   ├── CT1(8).png
│   └── CT1(9).png
├── FLAIR
│   ├── FLAIR(1).png
│   ├── FLAIR(10).png
│   ├── FLAIR(11).png
│   ├── FLAIR(12).png
│   ├── FLAIR(13).png
│   ├── FLAIR(14).png
│   ├── FLAIR(15).png
│   ├── FLAIR(16).png
│   ├── FLAIR(17).png
│   ├── FLAIR(18).png
│   ├── FLAIR(19).png
│   ├── FLAIR(2).png
│   ├── FLAIR(20).png
│   ├── FLAIR(21).png
│   ├── FLAIR(22).png
│   ├── FLAIR(23).png
│   ├── FLAIR(24).png
│   ├── FLAIR(25).png
│   ├── FLAIR(26).png
│   ├── FLAIR(27).png
│   ├── FLAIR(28).png
│   ├── FLAIR(29).png
│   ├── FLAIR(3).png
│   ├── FLAIR(4).png
│   ├── FLAIR(5).png
│   ├── FLAIR(6).png
│   ├── FLAIR(7).png
│   ├── FLAIR(8).png
│   └── FLAIR(9).png
└── results.tsv

Did you ever run into this issue? And, in general, what tree structure MRQy expects to work correctly? Is there an option to avoid saving the thumbnails?

Also, as a minor comment, the first lines in the output in this case reads:

MRQy is starting....
The number of patients is 4

But in reality, the number of patients is 2, while 4 is the number of series.

Thanks!

Input Issue

MRQy is not accepting the dicom images it is showing no of patients 0

This is the thing i am getting
MRQy is starting....
The number of patients is 0
The input folder is empty or includes unsupported files format!
Skipped the t-SNE and UMAP computation because of insufficient data. The UMAP and t-SNE process need at least 6 input data.
Traceback (most recent call last):
File "C:\Users\raman\MRQy-master\src\mrqy\QC.py", line 377, in
df = tsv_to_dataframe(address)
File "C:\Users\raman\MRQy-master\src\mrqy\QC.py", line 206, in tsv_to_dataframe
return pd.read_csv(tsvfileaddress, sep='\t', skiprows=2, header=0)
File "C:\Anaconda\lib\site-packages\pandas\util_decorators.py", line 311, in wrapper
return func(*args, **kwargs)
File "C:\Anaconda\lib\site-packages\pandas\io\parsers\readers.py", line 586, in read_csv
return _read(filepath_or_buffer, kwds)
File "C:\Anaconda\lib\site-packages\pandas\io\parsers\readers.py", line 482, in _read
parser = TextFileReader(filepath_or_buffer, **kwds)
File "C:\Anaconda\lib\site-packages\pandas\io\parsers\readers.py", line 811, in init
self._engine = self._make_engine(self.engine)
File "C:\Anaconda\lib\site-packages\pandas\io\parsers\readers.py", line 1040, in _make_engine
return mapping[engine](self.f, **self.options) # type: ignore[call-arg]
File "C:\Anaconda\lib\site-packages\pandas\io\parsers\c_parser_wrapper.py", line 51, in init
self._open_handles(src, kwds)
File "C:\Anaconda\lib\site-packages\pandas\io\parsers\base_parser.py", line 222, in _open_handles
self.handles = get_handle(
File "C:\Anaconda\lib\site-packages\pandas\io\common.py", line 702, in get_handle
handle = open(
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\raman\MRQy-master\src\mrqy\UserInterface\Data\gbm_raw\results.tsv'

Parallel

In our study we have thousands of scan sessions and I would like to run these in parallel. It seems though that the results.tsv file gets newly remade with every parallel run of the program. Is there a way to append to it while running it simultaneously? it seems that in the participant folder only the png files are saved and not any participant data that can be extracted afterwards in one go.
Thanks.

DATA

How can i get the TSV file and Data set for seeing the result

Installation instructions

Hi, I'd be very curious to try this tool, but I can't find the installation instructions mentioned here
Could you point me to where they are? Thanks!

QC.py npt recognized

This looks great and exactly what I need, but can't get past the install. I'm using Ubuntu 20.04, python 3.8

I followed the README instructions and I can launch the shell - setting up in my home .local directory
.local/share/virtualenvs/MRQy-yxYQvYdT/bin/activate

I can install mrqy
pipenv install .
Installing ....
Adding mrqy to Pipfile's [packages]...
✔ Installation Succeeded
Installing dependencies from Pipfile.lock (829554)...

and I can get the help to output to the screen
python -m mrqy.QC --help
usage: QC.py [-h] [-r R] [-s S] [-b B] [-u U] [-t T] [-c C] output_folder_name [inputdir [inputdir ...]]

But, when I try to run "pipenv run -m pytest tests/" I get "Error: the command -m could not be found within PATH or Pipfile's [scripts]."

What PATH variable is it looking for? There seems to be a PATH that was created in the .local/share/virtualenvs directory

Any help would be greatly appreciated. And, yes, I did pip install the requirements.txt without issue.

Pipfile Typo

Hello,

I noticed that there is a single quote on line 17 of the pipfile that is supposed to be a double quote. I received an error message when running the original pipfile, but everything seems to work if the single quote is changed to a double quote.

Thanks,
Josh

Please help cann't read data

I used pipenv to run the MRQY。
input:(a4020-WYmTOfA1) (base) C:\Users\a4020\Documents\GitHub\MRQy\src\mrqy>python QC.py MR_RAW 'C:\Users\a4020\Desktop\mrqy learning\MR-nii'

output:MRQy is starting....
The number of patients is 0
The input folder is empty or includes unsupported files format!
Skipped the t-SNE and UMAP computation because of insufficient data. The UMAP and t-SNE process need at least 6 input data.
Traceback (most recent call last):
File "QC.py", line 376, in
df = tsv_to_dataframe(address)
File "QC.py", line 205, in tsv_to_dataframe
return pd.read_csv(tsvfileaddress, sep='\t', skiprows=2, header=0)
File "C:\Users\a4020.virtualenvs\a4020-WYmTOfA1\lib\site-packages\pandas\io\parsers.py", line 688, in read_csv
return _read(filepath_or_buffer, kwds)
File "C:\Users\a4020.virtualenvs\a4020-WYmTOfA1\lib\site-packages\pandas\io\parsers.py", line 454, in _read
parser = TextFileReader(fp_or_buf, **kwds)
File "C:\Users\a4020.virtualenvs\a4020-WYmTOfA1\lib\site-packages\pandas\io\parsers.py", line 948, in init
self._make_engine(self.engine)
File "C:\Users\a4020.virtualenvs\a4020-WYmTOfA1\lib\site-packages\pandas\io\parsers.py", line 1180, in _make_engine
self._engine = CParserWrapper(self.f, **self.options)
File "C:\Users\a4020.virtualenvs\a4020-WYmTOfA1\lib\site-packages\pandas\io\parsers.py", line 2010, in init
self._reader = parsers.TextReader(src, **kwds)
File "pandas_libs\parsers.pyx", line 540, in pandas._libs.parsers.TextReader.cinit
pandas.errors.EmptyDataError: No columns to parse from file

sample_size error

Hello everyone,
I was trying to use your tool to analize some data but it seems I can't make it work.
I have followed the steps in the wiki but theese are the outputs.
I have also tried to manually insert the sample size value but the output is the same.

Python version is 3.6.9

image

image

Do you have any idea of what can it be?
Thank you for your help.

perplexity must be less than n_samples

Running QC4d.py on 4D BOLD images produces this error. Could you explain what's wrong? A tgz file is produced, but neither the t-SNE or UMAP plots are created. Thanks for your help.
Screenshot from 2023-11-19 13-18-16

Error running QC.py on brain scan.

Summary

Getting a value error when running QC.py on a sample brain scan.

Output

(MRQy-irixV0Tq) lodge@DESKTOP-TBEVFI2:~/code/MRQy$ python src/mrqy/QC.py ~/code/MRQy/output ~/code/MRQy/input
MRQy is starting....
The number of patients is 1
The number of 22 images are saved to /home/lodge/code/MRQy/UserInterface/Data//home/lodge/code/MRQy/output/Output_3D_File
1-1. The VRX of the patient with the name of <Output_3D_File> is 0.47
1-2. The VRY of the patient with the name of <Output_3D_File> is 0.47
1-3. The VRZ of the patient with the name of <Output_3D_File> is 5.00
1-4. The ROWS of the patient with the name of <Output_3D_File> is 512
1-5. The COLS of the patient with the name of <Output_3D_File> is 512
1-6. The NUM of the patient with the name of <Output_3D_File> is 22
1-7. The MEAN of the patient with the name of <Output_3D_File> is 264.68047264391714
1-8. The RNG of the patient with the name of <Output_3D_File> is 1217.0
1-9. The VAR of the patient with the name of <Output_3D_File> is 26972.86366286672
1-10. The CV of the patient with the name of <Output_3D_File> is 60.56001727509839
1-11. The CPP of the patient with the name of <Output_3D_File> is 0.0
1-12. The PSNR of the patient with the name of <Output_3D_File> is 16.035276287657798
1-13. The SNR1 of the patient with the name of <Output_3D_File> is 21.97046333358044
1-14. The SNR2 of the patient with the name of <Output_3D_File> is 115.58171760174017
1-15. The SNR3 of the patient with the name of <Output_3D_File> is 4.875157085735123
1-16. The SNR4 of the patient with the name of <Output_3D_File> is 16.6181236994002
1-17. The CNR of the patient with the name of <Output_3D_File> is 15.726563711378503
1-18. The CVP of the patient with the name of <Output_3D_File> is 0.2720244069104087
1-19. The CJV of the patient with the name of <Output_3D_File> is 0.6383621489661986
1-20. The EFC of the patient with the name of <Output_3D_File> is 2.1080743214048123
1-21. The FBER of the patient with the name of <Output_3D_File> is 0.0
The results are updated.
Traceback (most recent call last):
  File "src/mrqy/QC.py", line 369, in <module>
    df = cleanup(address, 30)
  File "src/mrqy/QC.py", line 228, in cleanup
    tsne_umap(df, per)
  File "src/mrqy/QC.py", line 217, in tsne_umap
    tsne_obj = tsne.fit_transform(ds)
  File "/home/lodge/.local/share/virtualenvs/MRQy-irixV0Tq/lib/python3.8/site-packages/sklearn/manifold/_t_sne.py", line 932, in fit_transform
    embedding = self._fit(X)
  File "/home/lodge/.local/share/virtualenvs/MRQy-irixV0Tq/lib/python3.8/site-packages/sklearn/manifold/_t_sne.py", line 702, in _fit
    X = self._validate_data(X, accept_sparse=['csr'],
  File "/home/lodge/.local/share/virtualenvs/MRQy-irixV0Tq/lib/python3.8/site-packages/sklearn/base.py", line 421, in _validate_data
    X = check_array(X, **check_params)
  File "/home/lodge/.local/share/virtualenvs/MRQy-irixV0Tq/lib/python3.8/site-packages/sklearn/utils/validation.py", line 63, in inner_f
    return f(*args, **kwargs)
  File "/home/lodge/.local/share/virtualenvs/MRQy-irixV0Tq/lib/python3.8/site-packages/sklearn/utils/validation.py", line 726, in check_array
    raise ValueError("Found array with %d sample(s) (shape=%s) while a"
ValueError: Found array with 1 sample(s) (shape=(1, 21)) while a minimum of 2 is required.

Sample Data

This is the image upon which it fails: Output_3D_File.nii.gz

DLL load failed while importing _remap - module not found

Hi!

While testing whether the code is functional (python -m mrqy.QC --help) I have run into a few problems.

  1. The first error was "ModuleNotFoundError: No module named 'skimage' - Subsequently I ran pipenv install scikit-image
  2. After installing the scikit-image package I received the error: ImportError: DLL load failed while importing _remap: the specified module could not be found. Based on this post: scikit-image/scikit-image#4780 I ran pipenv install msvc-runtime, but am still getting the following error:
PS C:\Users\Mattea\MDACC\MRQy> pipenv install .
Installing ....
Adding mrqy to Pipfile's [packages]...
Installation Succeeded
Installing dependencies from Pipfile.lock (fd82fb)...
 ================================ 1/1 - 00:00:00
PS C:\Users\Mattea\MDACC\MRQy> python -m mrqy.QC --help
Traceback (most recent call last):
 File "C:\Users\Mattea\anaconda3\lib\runpy.py", line 194, in _run_module_as_main
   return _run_code(code, main_globals, None,
 File "C:\Users\Mattea\anaconda3\lib\runpy.py", line 87, in _run_code
   exec(code, run_globals)
 File "C:\Users\Mattea\.virtualenvs\MRQy-0a-sfUiD\lib\site-packages\mrqy\QC.py", line 11, in <module>
   import mrqy.QCF as QCF ## import QCF
 File "C:\Users\Mattea\.virtualenvs\MRQy-0a-sfUiD\lib\site-packages\mrqy\QCF.py", line 17, in <module>
   from skimage.filters import threshold_otsu
 File "C:\Users\Mattea\.virtualenvs\MRQy-0a-sfUiD\lib\site-packages\skimage\__init__.py", line 127, in <module>
   from .util.dtype import (img_as_float32,
 File "C:\Users\Mattea\.virtualenvs\MRQy-0a-sfUiD\lib\site-packages\skimage\util\__init__.py", line 17, in <module>
   from ._map_array import map_array
 File "C:\Users\Mattea\.virtualenvs\MRQy-0a-sfUiD\lib\site-packages\skimage\util\_map_array.py", line 2, in <module>
   from ._remap import _map_array
ImportError: DLL load failed while importing _remap: The specified module could not be found.

Any tips or suggestions would be greatly appreciated!
Thanks,
Mattea

Front-end View Problem Loading Images

Hello,

It seems like the front-end view is only able to load images that are stored in the UserInterface subdirectory of the main MRQy directory. Is the front-end view supposed to be capable of loading images stored outside the UserInterface subdirectory, and if it is then how can those images be loaded?

Thanks,
Josh

ModuleNotFoundError: No module named 'QCF'

Hello,

I was getting the ModuleNotFoundError: No module named 'QCF' issue when running the test example python -m mrqy.QC --help.

I solved this by going into the virtual environment site-packages and editing line 11 on the QC.py to import mrqy.QCF as QCF, which solved my issue. I don't know if you ever run into anything like this. The package mrqy included both files, but I had to point it to the package itself to import QCF it looks like. I'm on python 3.6.8.

Cheers,
Vasco

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.