siq


Namesiq JSON
Version 0.3.4 PyPI version JSON
download
home_pagehttps://github.com/stnava/siq
Summarydeep perceptual resampling and super resolution with antspyx
upload_time2023-08-21 12:29:29
maintainer
docs_urlNone
authorAvants, Gosselin, Tustison, Reardon
requires_python
licenseApache 2.0
keywords
VCS
bugtrack_url
requirements h5py numpy pandas antspyx antspynet antspyt1w tensorflow pathlib
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # SIQ - super-resolution image quantification

## deep perceptual resampling and super-resolution for (medical) imaging

install by calling (within the source directory):

```
python setup.py install
```

or install via `pip install siq`

# what this will do

facilitates:

* creating training and testing data for deep networks

* generating and testing perceptual losses in 2D and 3D

* general training and inference functions for deep networks

* intuitive weighting of multiple losses

* anisotropic super-resolution

* evaluation strategies for the above

# first time setup

```python
import antspyt1w
antspyt1w.get_data( force_download=True )
# import siq     # FIXME - for later
# siq.get_data( force_download=True )
```

NOTE: `get_data` has a `force_download` option to make sure the latest
package data is installed.

# example processing

```python
import os
import siq
import glob
import ants
fns=glob.glob( os.path.expanduser( "~/.antspyt1w/2*T1w*gz" ) )
import tensorflow as tf
ofn = os.path.expanduser("~/code/DPR/models/dsr3d_2up_64_256_6_3_v0.0zzz.h5")
if os.path.exists( ofn ):
    print("existing model") # should always initialize with pre-trained model
    mdl = tf.keras.models.load_model( ofn, compile=False )
else:
    print("default model - initialized with random weights")
    mdl = siq.default_dbpn( [2,2,2] ) # should match ratio of high to low size patches
myoutprefix = '/tmp/XXX'
training_path = siq.train(
    mdl, 
    fns[0:3], 
    fns[0:3], 
    output_prefix=myoutprefix,
    target_patch_size=[32,32,32],
    target_patch_size_low=[16,16,16],
    n_test=2, 
    learning_rate=5e-05, 
    feature_layer=6, 
    feature=2, 
    tv=0.1,
    max_iterations=2, 
    verbose=True)
training_path.to_csv( myoutprefix + "_training.csv" )
image = ants.image_read( fns[0] )
image = ants.resample_image( image, [48,48,48] ) # downsample for speed in testing
test = siq.inference( image, mdl )
```

see also: the training scripts in `tests`.

## todo

1. numpy read/write

2. test/fix 2D

## your compute environment

```bash
export TF_ENABLE_ONEDNN_OPTS=1 # for CPU

total_cpu_cores=$(nproc)
number_sockets=$(($(grep "^physical id" /proc/cpuinfo | awk '{print $4}' | sort -un | tail -1)+1))
number_cpu_cores=$(( (total_cpu_cores/2) / number_sockets))

echo "number of CPU cores per socket: $number_cpu_cores";
echo "number of socket: $number_sockets";

echo "Physical cores:"
egrep '^core id' /proc/cpuinfo | sort -u | wc -l

echo "Logical cores:"

egrep '^processor' /proc/cpuinfo | sort -u | wc -l

echo "Physical cpus (separate chips):"

egrep '^physical id' /proc/cpuinfo | sort -u | wc -l

```

## to publish a release

```
rm -r -f build/ antspymm.egg-info/ dist/
python3 setup.py sdist bdist_wheel
python3 -m twine upload -u username -p password  dist/*
```


## notes on cpu environment

```
# dd=/home/ubuntu/miniconda3/condabin/conda
# conda update -n base -c defaults conda
# conda init bash
# conda create -n ai3 python=3.9
# conda activate ai3 
# pip3 install --upgrade pip
py=python3 # "sudo /opt/parallelcluster/pyenv/versions/3.7.10/envs/awsbatch_virtualenv/bin/python3.7"

$py -m pip install --upgrade pip

# python3.7 -m pip uninstall tensorflow antspynet dipy patsy tensorboard tensorflow-probability -y
$py -m pip install nibabel PyNomaly scipy 
$py -m pip install antspyx 
$py -m pip install dipy 
$py -m pip install antspyt1w 
$py -m pip install antspymm 
$py -m pip install antspynet
$py -m pip install siq
$py -m pip uninstall tensorflow -y
$py -m pip install intel-tensorflow # -avx512==2.9.1
$py -m pip install tensorflow_probability
$py -m pip install keras
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/stnava/siq",
    "name": "siq",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Avants, Gosselin, Tustison, Reardon",
    "author_email": "stnava@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/ac/e8/7ff42a4497f42702b1d733ae82b693e8fa47e0bdb7a9da9ade4a683e8604/siq-0.3.4.tar.gz",
    "platform": null,
    "description": "# SIQ - super-resolution image quantification\n\n## deep perceptual resampling and super-resolution for (medical) imaging\n\ninstall by calling (within the source directory):\n\n```\npython setup.py install\n```\n\nor install via `pip install siq`\n\n# what this will do\n\nfacilitates:\n\n* creating training and testing data for deep networks\n\n* generating and testing perceptual losses in 2D and 3D\n\n* general training and inference functions for deep networks\n\n* intuitive weighting of multiple losses\n\n* anisotropic super-resolution\n\n* evaluation strategies for the above\n\n# first time setup\n\n```python\nimport antspyt1w\nantspyt1w.get_data( force_download=True )\n# import siq     # FIXME - for later\n# siq.get_data( force_download=True )\n```\n\nNOTE: `get_data` has a `force_download` option to make sure the latest\npackage data is installed.\n\n# example processing\n\n```python\nimport os\nimport siq\nimport glob\nimport ants\nfns=glob.glob( os.path.expanduser( \"~/.antspyt1w/2*T1w*gz\" ) )\nimport tensorflow as tf\nofn = os.path.expanduser(\"~/code/DPR/models/dsr3d_2up_64_256_6_3_v0.0zzz.h5\")\nif os.path.exists( ofn ):\n    print(\"existing model\") # should always initialize with pre-trained model\n    mdl = tf.keras.models.load_model( ofn, compile=False )\nelse:\n    print(\"default model - initialized with random weights\")\n    mdl = siq.default_dbpn( [2,2,2] ) # should match ratio of high to low size patches\nmyoutprefix = '/tmp/XXX'\ntraining_path = siq.train(\n    mdl, \n    fns[0:3], \n    fns[0:3], \n    output_prefix=myoutprefix,\n    target_patch_size=[32,32,32],\n    target_patch_size_low=[16,16,16],\n    n_test=2, \n    learning_rate=5e-05, \n    feature_layer=6, \n    feature=2, \n    tv=0.1,\n    max_iterations=2, \n    verbose=True)\ntraining_path.to_csv( myoutprefix + \"_training.csv\" )\nimage = ants.image_read( fns[0] )\nimage = ants.resample_image( image, [48,48,48] ) # downsample for speed in testing\ntest = siq.inference( image, mdl )\n```\n\nsee also: the training scripts in `tests`.\n\n## todo\n\n1. numpy read/write\n\n2. test/fix 2D\n\n## your compute environment\n\n```bash\nexport TF_ENABLE_ONEDNN_OPTS=1 # for CPU\n\ntotal_cpu_cores=$(nproc)\nnumber_sockets=$(($(grep \"^physical id\" /proc/cpuinfo | awk '{print $4}' | sort -un | tail -1)+1))\nnumber_cpu_cores=$(( (total_cpu_cores/2) / number_sockets))\n\necho \"number of CPU cores per socket: $number_cpu_cores\";\necho \"number of socket: $number_sockets\";\n\necho \"Physical cores:\"\negrep '^core id' /proc/cpuinfo | sort -u | wc -l\n\necho \"Logical cores:\"\n\negrep '^processor' /proc/cpuinfo | sort -u | wc -l\n\necho \"Physical cpus (separate chips):\"\n\negrep '^physical id' /proc/cpuinfo | sort -u | wc -l\n\n```\n\n## to publish a release\n\n```\nrm -r -f build/ antspymm.egg-info/ dist/\npython3 setup.py sdist bdist_wheel\npython3 -m twine upload -u username -p password  dist/*\n```\n\n\n## notes on cpu environment\n\n```\n# dd=/home/ubuntu/miniconda3/condabin/conda\n# conda update -n base -c defaults conda\n# conda init bash\n# conda create -n ai3 python=3.9\n# conda activate ai3 \n# pip3 install --upgrade pip\npy=python3 # \"sudo /opt/parallelcluster/pyenv/versions/3.7.10/envs/awsbatch_virtualenv/bin/python3.7\"\n\n$py -m pip install --upgrade pip\n\n# python3.7 -m pip uninstall tensorflow antspynet dipy patsy tensorboard tensorflow-probability -y\n$py -m pip install nibabel PyNomaly scipy \n$py -m pip install antspyx \n$py -m pip install dipy \n$py -m pip install antspyt1w \n$py -m pip install antspymm \n$py -m pip install antspynet\n$py -m pip install siq\n$py -m pip uninstall tensorflow -y\n$py -m pip install intel-tensorflow # -avx512==2.9.1\n$py -m pip install tensorflow_probability\n$py -m pip install keras\n```\n",
    "bugtrack_url": null,
    "license": "Apache 2.0",
    "summary": "deep perceptual resampling and super resolution with antspyx",
    "version": "0.3.4",
    "project_urls": {
        "Homepage": "https://github.com/stnava/siq"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2627b56e38f46478eeda80a30a4e547b37506dac71dc680f08b233207e117721",
                "md5": "00041b8712c767c97b5c1ad48b6add05",
                "sha256": "b03513cf67d393a1014be54595bbf055c804965929adf630e6cb0508250420bb"
            },
            "downloads": -1,
            "filename": "siq-0.3.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "00041b8712c767c97b5c1ad48b6add05",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 19184,
            "upload_time": "2023-08-21T12:29:28",
            "upload_time_iso_8601": "2023-08-21T12:29:28.454985Z",
            "url": "https://files.pythonhosted.org/packages/26/27/b56e38f46478eeda80a30a4e547b37506dac71dc680f08b233207e117721/siq-0.3.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ace87ff42a4497f42702b1d733ae82b693e8fa47e0bdb7a9da9ade4a683e8604",
                "md5": "4bf807e4826cad99b1f2b6beef9483f2",
                "sha256": "2ab8ddfa16d4e4a4cb1aaee83365c5af800353bbaa9027ba2fda2b2ac297ffc8"
            },
            "downloads": -1,
            "filename": "siq-0.3.4.tar.gz",
            "has_sig": false,
            "md5_digest": "4bf807e4826cad99b1f2b6beef9483f2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 20743,
            "upload_time": "2023-08-21T12:29:29",
            "upload_time_iso_8601": "2023-08-21T12:29:29.576483Z",
            "url": "https://files.pythonhosted.org/packages/ac/e8/7ff42a4497f42702b1d733ae82b693e8fa47e0bdb7a9da9ade4a683e8604/siq-0.3.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-21 12:29:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "stnava",
    "github_project": "siq",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "h5py",
            "specs": [
                [
                    ">=",
                    "2.10.0"
                ]
            ]
        },
        {
            "name": "numpy",
            "specs": [
                [
                    ">=",
                    "1.19.4"
                ]
            ]
        },
        {
            "name": "pandas",
            "specs": [
                [
                    ">=",
                    "1.0.1"
                ]
            ]
        },
        {
            "name": "antspyx",
            "specs": [
                [
                    ">=",
                    "0.2.7"
                ]
            ]
        },
        {
            "name": "antspynet",
            "specs": [
                [
                    ">=",
                    "0.0"
                ]
            ]
        },
        {
            "name": "antspyt1w",
            "specs": [
                [
                    ">=",
                    "0.2.3"
                ]
            ]
        },
        {
            "name": "tensorflow",
            "specs": [
                [
                    ">=",
                    "2.2"
                ]
            ]
        },
        {
            "name": "pathlib",
            "specs": []
        }
    ],
    "lcname": "siq"
}
        
Elapsed time: 0.15991s