def _validate_channel_definition(self, jp2h, colr):
cdef_lst = [j for (j, box) in enumerate(jp2h.box)<EOL>if box.box_id == '<STR_LIT>']<EOL>if len(cdef_lst) > <NUM_LIT:1>:<EOL><INDENT>msg = ("<STR_LIT>"<EOL>"<STR_LIT>")<EOL>raise IOError(msg)<EOL><DEDENT>elif len(cdef_lst) == <NUM_LIT:1>:<EOL><INDENT>cdef = jp2h.box[cdef_lst[<NUM_LIT:0>]]<EOL>if colr.colorspace == core.SRGB:<EOL><INDENT>if any([chan + <NUM_LIT:1> not in cdef.association or<EOL>cdef.channel_type[chan] != <NUM_LIT:0> for chan in [<NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:2>]]):<EOL><INDENT>msg = ("<STR_LIT>"<EOL>"<STR_LIT>")<EOL>raise IOError(msg)<EOL><DEDENT><DEDENT>elif colr.colorspace == core.GREYSCALE:<EOL><INDENT>if <NUM_LIT:0> not in cdef.channel_type:<EOL><INDENT>msg = ("<STR_LIT>"<EOL>"<STR_LIT>")<EOL>raise IOError(msg)<EOL><DEDENT><DEDENT><DEDENT>
Validate the channel definition box.