# [Neuroimaging] compute_mask - algorithm changed?

bthirion bertrand.thirion at inria.fr
Tue Sep 29 09:19:27 CEST 2015

```     Hi,

No, we're still using the Nichols "anti mode" heuristic:

delta = sorted_input[limiteinf + 1:limitesup + 1] \
- sorted_input[limiteinf:limitesup]
ia = delta.argmax()
threshold = 0.5 * (sorted_input[ia + limiteinf]
+ sorted_input[ia + limiteinf + 1])

But let me reiterate that this code is *dead*, and that nilearn
should be used for this kind of task.

Bertrand

On 29/09/2015 08:52, JB Poline wrote:
> Hi,
>
> Fyi, I had to tweak the values to get a reasonable answer on some
> data, but generally works well
> cheers
> JB
>
> On Tue, Sep 29, 2015 at 2:18 AM, Matthew Brett <matthew.brett at gmail.com> wrote:
>> On Mon, Sep 28, 2015 at 5:13 PM, Matthew Brett <matthew.brett at gmail.com> wrote:
>>> Hi guys,
>>>
>>>
>>> The docstring for that function has:
>>>
>>>      Compute and write the mask of an image based on the grey level
>>>      This is based on an heuristic proposed by T.Nichols:
>>>      find the least dense point of the histogram, between fractions
>>>      m and M of the total image histogram.
>>>
>>> but I think the actual algorithm is:
>>>
>>>      * Sort values;
>>>      * Remove m from start and M from end of the sorted vector;
>>>      * Find the value to value difference;
>>>      * Use the value corresponding to the position of the largest
>>> difference as a threshold.
>>>
>>> Is that right?   Did the algorithm change at some point?
>> Ah - sorry - with a moment's reflection, I see that the large
>> difference between the sorted values also represents a local point of
>> low histogram density...
>>
>> Cheers2,
>>
>> Matthew
>> _______________________________________________
>> Neuroimaging mailing list
>> Neuroimaging at python.org
>> https://mail.python.org/mailman/listinfo/neuroimaging
> _______________________________________________
> Neuroimaging mailing list
> Neuroimaging at python.org
> https://mail.python.org/mailman/listinfo/neuroimaging

```