FNNDSC / ami

AMI Medical Imaging (AMI) JS ToolKit
https://fnndsc.github.io/ami/#viewers_upload
MIT License
714 stars 212 forks source link

Reduce bundle size #324

Open NicolasRannou opened 6 years ago

NicolasRannou commented 6 years ago

Lots of code from THREEJS is not shaked-out and OpenJPEG is way too big.

> yarn analyze:ami:prod 

screen shot 2018-07-23 at 1 38 11 pm

NicolasRannou commented 6 years ago

https://github.com/FNNDSC/ami/pull/326

NicolasRannou commented 6 years ago
screen shot 2018-07-25 at 9 48 40 am
NicolasRannou commented 6 years ago

Pako is being included 2 times. (-200kB)

OpenJPEG is huge. Can we get rid of JPX/JPEG decoder then?

Freesurder segmentation preset should not be part of the bundle. (-100kB)

JSibir commented 6 years ago

OpenJPEG can be excluded from package. If users want to work with J2K, AMI documentation will force them to load OpenJPEG script before AMI, like it done in Cornerstone.

NicolasRannou commented 6 years ago

Interesting - do you have a link to where they would do in Cornerstone?

In AMI, the data "parsers" and "decoders" is the most expensive thing

JSibir commented 6 years ago

https://github.com/cornerstonejs/cornerstoneWADOImageLoader/blob/master/docs/Codecs.md https://rawgit.com/cornerstonejs/cornerstoneWADOImageLoader/master/examples/dicomfile/index.html L112-L133

NicolasRannou commented 6 years ago

Thanks that's useful!

What I am thinking now is that: 1- load all codecs on demand in ami (somehow)

// in dicom parser
if (j2k) {
  // get j2k decoder through ajax file, then when loaded, continue
}

or 2- provide codecs in the loader/parser constructors

const volumeLoader = new VolumeLoader({
  decoders:
  { 
    j2k: J2K, // J2K constructor
  }
})