# curvanato
local curvature quantification for anatomical data
### **Installation & Testing**
To install the package locally, navigate to the package root and run:
```bash
pip install .
```
## Usage
```python
import ants
import antspynet
import antspyt1w
import curvanato
import re
import os # For checking file existence
import pandas as pd
import numpy as np
os.environ["ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS"] = "32"
# ANTPD data from open neuro
fn='.//bids/sub-RC4111/ses-1/anat/sub-RC4111_ses-1_T1w.nii.gz' # easy
fn='.//bids/sub-RC4103/ses-1/anat/sub-RC4103_ses-1_T1w.nii.gz'
fn='./bids//sub-RC4110/ses-2/anat/sub-RC4110_ses-2_T1w.nii.gz'
if os.path.exists(fn):
t1=ants.image_read( fn )
t1=ants.resample_image( t1, [0.5, 0.5, 0.5], use_voxels=False, interp_type=0 )
hoafn = re.sub( ".nii.gz", "_hoa.nii.gz" , fn )
if not os.path.exists(hoafn):
hoa = antspynet.harvard_oxford_atlas_labeling(t1, verbose=True)['segmentation_image']
ants.image_write( hoa, hoafn)
hoa = ants.image_read( hoafn )
citfn = re.sub( ".nii.gz", "_cit168.nii.gz" , fn )
if not os.path.exists(citfn):
t1b = antspynet.brain_extraction( t1, modality="t1threetissue" )['segmentation_image'].threshold_image(1,1)
t1r = ants.rank_intensity( t1 * t1b )
cit = antspyt1w.deep_cit168( t1r, verbose=True)['segmentation']
ants.image_write( cit, citfn)
cit = ants.image_read( citfn )
###################################################################################
###################################################################################
###################################################################################
###################################################################################
ctype='cit'
tcaudL=curvanato.load_labeled_caudate( option='hmt', binarize=False, label=[1,3,5] )
tcaudR=curvanato.load_labeled_caudate( option='hmt', binarize=False, label=[2,4,6] )
vlab=None
leftside=True
gr=0
subd=0
otherside=True
if otherside:
ccfn = [
re.sub( ".nii.gz", "_"+ctype+"Rkappa.nii.gz" , fn ),
re.sub( ".nii.gz", "_"+ctype+"R.nii.gz" , fn ),
re.sub( ".nii.gz", "_"+ctype+"Rthk.nii.gz" , fn ),
re.sub( ".nii.gz", "_"+ctype+"Rkappa.csv" , fn ),
re.sub( ".nii.gz", "_"+ctype+"Rkappa.png" , fn ),
re.sub( ".nii.gz", "_"+ctype+"Rthk.png" , fn ) ]
pcaud=[3,4]
plabs=[4]
if ctype == 'cit':
mytl=18
xx = curvanato.t1w_caudcurv( cit, target_label=mytl, ventricle_label=vlab,
prior_labels=pcaud, prior_target_label=plabs, subdivide=subd, grid=gr,
priorparcellation=tcaudR, plot=True,
verbose=True )
ants.plot( xx[0], xx[1], crop=True, axis=2, nslices=21, ncol=7, filename=ccfn[4] )
ants.plot( xx[0], xx[2], crop=True, axis=2, nslices=21, ncol=7, filename=ccfn[5] )
for j in range(3):
ants.image_write( xx[j], ccfn[j] )
xx[3].to_csv( ccfn[3] )
if leftside:
mytl=2
ccfn = [
re.sub( ".nii.gz", "_"+ctype+"Lkappa.nii.gz" , fn ),
re.sub( ".nii.gz", "_"+ctype+"L.nii.gz" , fn ),
re.sub( ".nii.gz", "_"+ctype+"Lthk.nii.gz" , fn ),
re.sub( ".nii.gz", "_"+ctype+"Lkappa.csv" , fn ),
re.sub( ".nii.gz", "_"+ctype+"Lkappa.png" , fn ),
re.sub( ".nii.gz", "_"+ctype+"Lthk.png" , fn ) ]
print("Begin " + fn + " caud kap")
pcaud=[1,2]
plabs=[2]
xx = curvanato.t1w_caudcurv( cit, target_label=2, ventricle_label=vlab,
prior_labels=pcaud, prior_target_label=plabs, subdivide=subd, grid=gr,
priorparcellation=tcaudL, plot=True, searchrange=20,
verbose=True )
ants.plot( xx[0], xx[1], crop=True, axis=2, nslices=21, ncol=7, filename=ccfn[4] )
ants.plot( xx[0], xx[1], crop=True, axis=2, nslices=21, ncol=7, filename=ccfn[5] )
for j in range(3):
ants.image_write( xx[j], ccfn[j] )
xx[3].to_csv( ccfn[3] )
```
## Example data
this package has been tested on [ANTPD data from openneuro](https://openneuro.org/datasets/ds001907/versions/2.0.3).
could also try data [here](https://openneuro.org/datasets/ds004560/versions/1.0.1) which included repeated T1w acquisitions on same subjects but with different parameters. however, last time i tried this, the link was not working.
```
rm -r -f build/ curvanato.egg-info/ dist/
python3 -m build .
python3 -m pip install --upgrade twine
python3 -m twine upload --repository antspyt1w dist/*
```
Raw data
{
"_id": null,
"home_page": null,
"name": "curvanato",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "curvanato, caudate, medical image processing",
"author": "Dorian Pustina",
"author_email": "\"Brian B. Avants\" <stnava@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/c3/44/324b4cb348172d0eabfea16efbe60c61903496d777d23253cc40c603d930/curvanato-1.0.0.tar.gz",
"platform": null,
"description": "# curvanato\n\nlocal curvature quantification for anatomical data\n\n\n### **Installation & Testing**\n\nTo install the package locally, navigate to the package root and run:\n\n```bash\npip install .\n```\n\n\n## Usage\n\n```python\nimport ants\nimport antspynet\nimport antspyt1w\nimport curvanato\nimport re\nimport os # For checking file existence\nimport pandas as pd\nimport numpy as np\nos.environ[\"ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS\"] = \"32\"\n# ANTPD data from open neuro\nfn='.//bids/sub-RC4111/ses-1/anat/sub-RC4111_ses-1_T1w.nii.gz' # easy\nfn='.//bids/sub-RC4103/ses-1/anat/sub-RC4103_ses-1_T1w.nii.gz'\nfn='./bids//sub-RC4110/ses-2/anat/sub-RC4110_ses-2_T1w.nii.gz'\nif os.path.exists(fn):\n t1=ants.image_read( fn )\n t1=ants.resample_image( t1, [0.5, 0.5, 0.5], use_voxels=False, interp_type=0 )\n hoafn = re.sub( \".nii.gz\", \"_hoa.nii.gz\" , fn )\n if not os.path.exists(hoafn):\n hoa = antspynet.harvard_oxford_atlas_labeling(t1, verbose=True)['segmentation_image']\n ants.image_write( hoa, hoafn)\n hoa = ants.image_read( hoafn )\n citfn = re.sub( \".nii.gz\", \"_cit168.nii.gz\" , fn )\n if not os.path.exists(citfn):\n t1b = antspynet.brain_extraction( t1, modality=\"t1threetissue\" )['segmentation_image'].threshold_image(1,1)\n t1r = ants.rank_intensity( t1 * t1b )\n cit = antspyt1w.deep_cit168( t1r, verbose=True)['segmentation']\n ants.image_write( cit, citfn)\n cit = ants.image_read( citfn )\n\n###################################################################################\n###################################################################################\n###################################################################################\n###################################################################################\nctype='cit'\ntcaudL=curvanato.load_labeled_caudate( option='hmt', binarize=False, label=[1,3,5] )\ntcaudR=curvanato.load_labeled_caudate( option='hmt', binarize=False, label=[2,4,6] )\nvlab=None\nleftside=True\ngr=0\nsubd=0\notherside=True\nif otherside:\n ccfn = [\n re.sub( \".nii.gz\", \"_\"+ctype+\"Rkappa.nii.gz\" , fn ), \n re.sub( \".nii.gz\", \"_\"+ctype+\"R.nii.gz\" , fn ),\n re.sub( \".nii.gz\", \"_\"+ctype+\"Rthk.nii.gz\" , fn ),\n re.sub( \".nii.gz\", \"_\"+ctype+\"Rkappa.csv\" , fn ),\n re.sub( \".nii.gz\", \"_\"+ctype+\"Rkappa.png\" , fn ),\n re.sub( \".nii.gz\", \"_\"+ctype+\"Rthk.png\" , fn ) ]\n pcaud=[3,4]\n plabs=[4]\n if ctype == 'cit':\n mytl=18\n xx = curvanato.t1w_caudcurv( cit, target_label=mytl, ventricle_label=vlab, \n prior_labels=pcaud, prior_target_label=plabs, subdivide=subd, grid=gr,\n priorparcellation=tcaudR, plot=True,\n verbose=True )\n ants.plot( xx[0], xx[1], crop=True, axis=2, nslices=21, ncol=7, filename=ccfn[4] )\n ants.plot( xx[0], xx[2], crop=True, axis=2, nslices=21, ncol=7, filename=ccfn[5] )\n for j in range(3):\n ants.image_write( xx[j], ccfn[j] )\n xx[3].to_csv( ccfn[3] )\n\nif leftside:\n mytl=2\n ccfn = [\n re.sub( \".nii.gz\", \"_\"+ctype+\"Lkappa.nii.gz\" , fn ), \n re.sub( \".nii.gz\", \"_\"+ctype+\"L.nii.gz\" , fn ),\n re.sub( \".nii.gz\", \"_\"+ctype+\"Lthk.nii.gz\" , fn ),\n re.sub( \".nii.gz\", \"_\"+ctype+\"Lkappa.csv\" , fn ),\n re.sub( \".nii.gz\", \"_\"+ctype+\"Lkappa.png\" , fn ),\n re.sub( \".nii.gz\", \"_\"+ctype+\"Lthk.png\" , fn ) ]\n print(\"Begin \" + fn + \" caud kap\")\n pcaud=[1,2]\n plabs=[2]\n xx = curvanato.t1w_caudcurv( cit, target_label=2, ventricle_label=vlab, \n prior_labels=pcaud, prior_target_label=plabs, subdivide=subd, grid=gr,\n priorparcellation=tcaudL, plot=True, searchrange=20,\n verbose=True )\n ants.plot( xx[0], xx[1], crop=True, axis=2, nslices=21, ncol=7, filename=ccfn[4] )\n ants.plot( xx[0], xx[1], crop=True, axis=2, nslices=21, ncol=7, filename=ccfn[5] )\n for j in range(3):\n ants.image_write( xx[j], ccfn[j] )\n xx[3].to_csv( ccfn[3] )\n\n\n\n```\n\n\n## Example data\n\nthis package has been tested on [ANTPD data from openneuro](https://openneuro.org/datasets/ds001907/versions/2.0.3).\n\ncould also try data [here](https://openneuro.org/datasets/ds004560/versions/1.0.1) which included repeated T1w acquisitions on same subjects but with different parameters. however, last time i tried this, the link was not working.\n\n\n```\nrm -r -f build/ curvanato.egg-info/ dist/\npython3 -m build .\npython3 -m pip install --upgrade twine\npython3 -m twine upload --repository antspyt1w dist/*\n```\n\n",
"bugtrack_url": null,
"license": "Apache License 2.0",
"summary": "Anatomical curvature processing for medical images.",
"version": "1.0.0",
"project_urls": {
"homepage": "https://github.com/stnava/curvanato"
},
"split_keywords": [
"curvanato",
" caudate",
" medical image processing"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "12093592fc48f16fac3d3b8beb82aaf8ba1eec8985b959dbdde8706d6ddf5384",
"md5": "cb302e77977e519b30ac1a1e1bf858c6",
"sha256": "3a226702e806e15542faf80743c0612d4e57c494eb5ce0348366a6a46e740b4b"
},
"downloads": -1,
"filename": "curvanato-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "cb302e77977e519b30ac1a1e1bf858c6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 85015,
"upload_time": "2024-12-06T17:43:06",
"upload_time_iso_8601": "2024-12-06T17:43:06.305963Z",
"url": "https://files.pythonhosted.org/packages/12/09/3592fc48f16fac3d3b8beb82aaf8ba1eec8985b959dbdde8706d6ddf5384/curvanato-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c344324b4cb348172d0eabfea16efbe60c61903496d777d23253cc40c603d930",
"md5": "76ea352f72c7a8532e4aae1c6abbb87a",
"sha256": "5b9331a266efd26a931b723c4ed84d1ddd59334ecf5ded1ec7476d022dd72431"
},
"downloads": -1,
"filename": "curvanato-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "76ea352f72c7a8532e4aae1c6abbb87a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 92209,
"upload_time": "2024-12-06T17:43:07",
"upload_time_iso_8601": "2024-12-06T17:43:07.575322Z",
"url": "https://files.pythonhosted.org/packages/c3/44/324b4cb348172d0eabfea16efbe60c61903496d777d23253cc40c603d930/curvanato-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-06 17:43:07",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "stnava",
"github_project": "curvanato",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "curvanato"
}