Convert nii.gz into DICOM series through python

I did according to Create DICOM series using python

But it is throwing in getNode raise MRMLNodeNotFoundException(“could not find nodes in the scene by name or id ‘%s’” % (pattern if (isinstance(pattern, str)) else “”))
slicer.util.MRMLNodeNotFoundException: could not find nodes in the scene by name or id.

I want python script so I can convert ni.gz files into DICOM series.