An image decoding method performed by a decoding apparatus, the method comprising: obtaining prediction related information and residual related information for a current block from a bitstream; deriving transform coefficients for the current block based on the residual related information; and generating residual samples of the current block based on the transform coefficients, wherein whether the residual related information includes low frequency non-separable transform, LFNST, index information related to one of transform kernels in an LFNST transform set or not for the current block is determined in response to an enabled flag for LFNST and a matrix based intra prediction, MIP, flag, wherein in response to the enabled flag representing that the LFNST is enabled and the MIP flag representing that the MIP is not applied, the residual related information includes the LFNST index information, wherein generating the residual samples comprises: deriving modified transform coefficients from the transform coefficients based on the LFNST index information; and generating the residual samples based on the modified transform coefficients, wherein the MIP flag represents whether MIP is applied to the current block, wherein in response to the MIP being applied to the current block, prediction samples of the current block are derived by reducing, through averaging, neighboring reference samples of the current block, performing a matrix-vector-multiplication on the reduced neighboring reference samples, and adding an offset vector to values on which the matrix-vector-multiplication is performed, and wherein the MIP flag is included in the prediction related information. obtaining prediction related information and residual related information for a current block from a bitstream; deriving transform coefficients for the current block based on the residual related information; and generating residual samples of the current block based on the transform coefficients, wherein whether the residual related information includes low frequency non-separable transform, LFNST, index information related to one of transform kernels in an LFNST transform set or not for the current block is determined in response to an enabled flag for LFNST and a matrix based intra prediction, MIP, flag, wherein in response to the enabled flag representing that the LFNST is enabled and the MIP flag representing that the MIP is not applied, the residual related information includes the LFNST index information, wherein generating the residual samples comprises: deriving modified transform coefficients from the transform coefficients based on the LFNST index information; and generating the residual samples based on the modified transform coefficients, wherein the MIP flag represents whether MIP is applied to the current block, wherein in response to the MIP being applied to the current block, prediction samples of the current block are derived by reducing, through averaging, neighboring reference samples of the current block, performing a matrix-vector-multiplication on the reduced neighboring reference samples, and adding an offset vector to values on which the matrix-vector-multiplication is performed, and wherein the MIP flag is included in the prediction related information. deriving modified transform coefficients from the transform coefficients based on the LFNST index information; and generating the residual samples based on the modified transform coefficients, wherein the MIP flag represents whether MIP is applied to the current block, wherein in response to the MIP being applied to the current block, prediction samples of the current block are derived by reducing, through averaging, neighboring reference samples of the current block, performing a matrix-vector-multiplication on the reduced neighboring reference samples, and adding an offset vector to values on which the matrix-vector-multiplication is performed, and wherein the MIP flag is included in the prediction related information.