<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def abp_n4(image, intensity_truncation=(0.025,0.975,256), mask=None, usen3=False):
 """ Truncate outlier intensities and bias correct with the N4 algorithm. ANTsR function: `abpN4` Arguments --------- image : ANTsImage image to correct and truncate intensity_truncation : 3-tuple quantiles for intensity truncation mask : ANTsImage (optional) mask for bias correction usen3 : boolean if True, use N3 bias correction instead of N4 Returns ------- ANTsImage Example ------- """

    if (not isinstance(intensity_truncation, (list,tuple))) or (len(intensity_truncation) != 3):
        raise ValueError('intensity_truncation must be list/tuple with 3 values')
    outimage = iMath(image, 'TruncateIntensity',
            intensity_truncation[0], intensity_truncation[1], intensity_truncation[2])
    if usen3 == True:
        outimage = n3_bias_field_correction(outimage, 4)
        outimage = n3_bias_field_correction(outimage, 2)
        return outimage
    else:
        outimage = n4_bias_field_correction(outimage, mask)
        return outimage