fslinfo
#!/bin/sh
# Use fslinfo to extract image dimensions. See fslhd for extraction of more info.
# find only the first matching line (-m 1) , print arg2:
# this will get the # of voxels in dimension 1 (usually x).
dim1=$(fslinfo img | grep -m 1 dim1 | awk '{print $2}')
# find only the first matching line, print arg2:
# this will get image dim this will get the voxel size in dimension 1 (usually x).
pixdim1=$(fslinfo img | grep -m 1 pixdim1 | awk '{print $2}')
# find only the first matching line (-m 1) , print arg2:
# this will get this will get the # of voxels in dimension 2 (usually y).
dim2=$(fslinfo img | grep -m 1 dim2 | awk '{print $2}')
# find only the first matching line, print arg2:
# this will get this will get the voxel size in dimension 2 (usually y).
pixdim2=$(fslinfo img | grep -m 1 pixdim2 | awk '{print $2}')
# find only the first matching line (-m 1) , print arg2:
# this will get the # of voxels in dimension 3 (usually z)
dim3=$(fslinfo img | grep -m 1 dim3 | awk '{print $2}')
# find only the first matching line, print arg2:
# this will get the voxel size in dimension 3 (usually z).
pixdim3=$(fslinfo img | grep -m 1 pixdim3 | awk '{print $2}')
# find only the first matching line (-m 1) , print arg2:
# this will get image dim
dim4=$(fslinfo img | grep -m 1 dim4 | awk '{print $2}')
# find only the first matching line, print arg2:
# this will get the # of voxels in dimension 4 (usually time, hence, the # of timepoints).
pixdim4=$(fslinfo img | grep -m 1 pixdim4 | awk '{print $2}')
echo "voxel dims: ${pixdim1} x ${pixdim2} x ${pixdim3} x ${pixdim4} "
echo "image dims: ${dim1} x ${dim2} x ${dim3} x ${dim4}"
Are there any code examples left?
New code examples in category Shell/Bash
-
Shell/Bash 2022-03-27 22:30:33 wise highlight ubuntu
-
Shell/Bash 2022-03-27 22:25:19 how to send a pull request in git
-
Shell/Bash 2022-03-27 21:55:06 how to open terminal in sublime text ubuntu
-
Shell/Bash 2022-03-27 21:25:19 how to switch branch
-
Shell/Bash 2022-03-27 21:20:25 python
-
Shell/Bash 2022-03-27 21:20:04 set user as admin gitlab
-
Shell/Bash 2022-03-27 21:10:09 apache2 mod_jk proxy to tomcat connector
-
Shell/Bash 2022-03-27 20:35:12 chown
-
Shell/Bash 2022-03-27 20:15:08 awk last match