Print

Print


Hi Sourajit,

A difficulty with this approach is that mean and standard deviation are
strongly influenced by outliers. Maybe using order statistics would me more
akin to what Winsor wanted. See for instance the Wikipedia article:
https://en.wikipedia.org/wiki/Winsorizing

To do that, you'd have to:

1) Mask the non-zero voxels
2) Run fslmeants, with the option --showall to have all the values in a
text file. Maybe some simple awk or sed processing to make sure there one
value per line.
3) Sort the values (the operating system should have a command called
"sort")
4) Use the OS commands "head" and "tail" to find out what is the lower and
upper quantile thresholds.
5) Use these instead of 3*SD in the script.

All the best,

Anderson




On 29 September 2016 at 22:13, sourajit mitra <[log in to unmask]> wrote:

> Hi Paul and Niels,
>            This is the code for WINSORIZATION  with I have pulled up from
> initial comments and later write up. Thanks all for the help.
>
> Please see the code and write your feedback. Is this look ok?
>
> #############extracting the mean and STD##############
>
> fslmaths all_OD_skeletonised.nii.gz -mas ROI_01_mas.nii.gz -thr 0
> all_OD_skeletonised_ROI_01.nii.gz
>
> fslstats all_OD_skeletonised_ROI_01.nii.gz -M > ROI_01_OD_M.txt
>
> fslstats all_OD_skeletonised_ROI_01.nii.gz -S > ROI_01_OD_S.txt
>
> mu=`more ROI_01_OD_M.txt`
> sd=`more ROI_01_OD_S.txt`
>
> 3sd_low=`echo "mu - 3*(sd)" | bc -l`
> 3sd_high=`echo "mu + 3*(sd)" | bc -l`
>
> #######generation of WINSORIZED ROI ################
>
> fslmaths all_OD_skeletonised_ROI_01.nii.gz -thr 3sd_low -uthr 3sd_high
> all_OD_skeletonised_ROI_01_thr.nii.gz
>
> fslmaths all_OD_skeletonised_ROI_01.nii.gz -uthr 3sd_low
> all_OD_skeletonised_ROI_01_lthr.nii.gz -bin -mul 3sd_low
> all_OD_skeletonised_ROI_01_lthr.nii.gz
>
> fslmaths all_OD_skeletonised_ROI_01.nii.gz -thr 3sd_high
> all_OD_skeletonised_ROI_01_lthr.nii.gz -bin -mul 3sd_high
> all_OD_skeletonised_ROI_01_uthr.nii.gz
>
> fslmaths 3sd_high all_OD_skeletonised_ROI_01_thr.nii.gz -add
> all_OD_skeletonised_ROI_01_lthr.nii.gz -add all_OD_skeletonised_ROI_01_uthr.nii.gz
> all_OD_skeletonised_ROI_01_win.nii.gz
>
> ########################Extracting mean and std from WINSORIZED ROI
>
> fslstats all_OD_skeletonised_ROI_01_win.nii.gz -M > ROI_01_OD_M_win.txt
>
> fslstats all_OD_skeletonised_ROI_01_win.nii.gz -M > ROI_01_OD_S_win.txt
>
> ###################END#####################
>
> Please see to it, and give your comments
>
> Kind regards
> sourajit
>
>
>
>
> On Thu, Sep 29, 2016 at 3:18 PM, Niels Bergsland <[log in to unmask]>
> wrote:
>
>> You could alternatively modify your previous command and use -min and
>> -max options instead.
>>
>>
>> On Thursday, September 29, 2016, Paul Robinson <[log in to unmask]>
>> wrote:
>>
>>> 'lo again.
>>>
>>> Sorry, it occurs to me that the code above simply truncates your roi
>>> which is not really Winsorization. However, it should remove those voxels
>>> which are 3 sds more or less than the mean, which is an okay first step. I
>>> would use fslmaths to create separate images of those voxels which exceed
>>> mu+/-3sd (-thr/-uthr), binarize them (-bin), and then multiply them by the
>>> appropriate constraint (-mul). Then you can simply add these three rois
>>> together.
>>>
>>> Best,
>>> Paul
>>>
>>>
>>> On Thu, Sep 29, 2016 at 9:57 AM, Paul Robinson <[log in to unmask]>
>>> wrote:
>>>
>>>> Hi, Sourajit
>>>>
>>>> Something like this?
>>>>
>>>> ### Or however you want to get the mean and sd
>>>> mu=`more ROI_01_OD_M.txt`
>>>> sd=`more ROI_01_OD_S.txt`
>>>>
>>>> 3sd_low=`echo "mu - 3*(sd)" | bc -l`
>>>> 3sd_high=`echo "mu + 3*(sd)" | bc -l`
>>>>
>>>> fslmaths all_OD_skeletonised_ROI_01.nii.gz -thr 3sd_low -uthr 3sd_high
>>>> all_OD_skeletonised_ROI_01_win.nii.gz
>>>>
>>>> Hope this helps,
>>>> Paul
>>>>
>>>> On Thu, Sep 29, 2016 at 9:44 AM, Sourajit Mitra Mustafi <
>>>> [log in to unmask]> wrote:
>>>>
>>>>> Dear admin,
>>>>>                                    I have extracted an ROI image in
>>>>> FSL and computed its mean, median and standard deviation for non-zero voxel
>>>>> using
>>>>> the following option.
>>>>>
>>>>> fslmaths all_OD_skeletonised.nii.gz -mas ROI_01_mas.nii.gz -thr 0
>>>>> all_OD_skeletonised_ROI_01.nii.gz
>>>>>
>>>>> fslstats -t all_OD_skeletonised_ROI_01.nii.gz -M > ROI_01_OD_M.txt
>>>>>
>>>>> fslstats -t all_OD_skeletonised_ROI_01.nii.gz -S > ROI_01_OD_S.txt
>>>>>
>>>>> fslstats -t all_OD_skeletonised_ROI_01.nii.gz -P 50 > ROI_01_OD_P.txt
>>>>>
>>>>> Is there is any way to WINSORIZE an image for non-zero voxel in FSL. I
>>>>> am trying a method based on ROI analysis and for that reason winsorization
>>>>> of image is important. fslstats doesn't provide that option. Please help me
>>>>> out.
>>>>>
>>>>> Kind regards
>>>>> sourajit
>>>>>
>>>>
>>>>
>>>
>>
>> --
>> Niels Bergsland
>> Integration Director
>> Buffalo Neuroimaging Analysis Center
>> 100 High St. Buffalo NY 14203
>> [log in to unmask]
>>
>
>