Tuple index out of range : Audio to spectrogram - python

I am trying to run an audio to spectrogram script, namely:
https://github.com/grrrr/nsgt/tree/master/examples
When I try python spectrogram.py myaudio.wav
I get the error:
Traceback (most recent call last):
File "spectrogram.py", line 111, in <module>
coefs = assemble_coeffs(c, ncoefs)
File "spectrogram.py", line 27, in assemble_coeffs
out = np.empty((ncoefs,cq0.shape[1],cq0.shape[2]), dtype=cq0.dtype)
IndexError: tuple index out of range
Am I doing something wrong?
Please advise! :)

you can run it with just the argument --matrixform added.
I suggest you to see this issue! from the github project it can help you

Related

Conversion not working properly using dicom2nifti

I have a series of dicom files (.dcm) for each patient that I want to convert to nii.gz files, but nothing happens (even error info) with the following conversion...
import dicom2nifti
dicom2nifti.settings.set_gdcmconv_path('C:/Program Files/GDCM 3.0/bin/gdcmconv.exe')
dicom2nifti.convert_directory('M0_1', 'M0_1.nii.gz')
The error occurs when trying other methods....
import dicom2nifti
dicom2nifti.settings.set_gdcmconv_path('C:/Program Files/GDCM 3.0/bin/gdcmconv.exe')
dicom2nifti.dicom_series_to_nifti('M0_1', 'M0_1.nii.gz')
Error Log:
Traceback (most recent call last):
File ".\test.py", line 5, in <module>
dicom2nifti.dicom_series_to_nifti('M0_1', 'M0_1.nii.gz')
File "D:\Anaconda3\envs\pydicom\lib\site-packages\dicom2nifti\convert_dicom.py", line 78, in dicom_series_to_nifti
return dicom_array_to_nifti(dicom_input, output_file, reorient_nifti)
File "D:\Anaconda3\envs\pydicom\lib\site-packages\dicom2nifti\convert_dicom.py", line 112, in dicom_array_to_nifti
if not are_imaging_dicoms(dicom_list):
File "D:\Anaconda3\envs\pydicom\lib\site-packages\dicom2nifti\convert_dicom.py", line 151, in are_imaging_dicoms
if common.is_philips(dicom_input):
File "D:\Anaconda3\envs\pydicom\lib\site-packages\dicom2nifti\common.py", line 102, in is_philips
header = dicom_input[0]
IndexError: list index out of range
File structure:
M0_1
|----IM-0001-0001.dcm
|----IM-0001-0002.dcm
........
|----IM-0001-000299.dcm
|----IM-0001-000300.dcm
Environment:
windows10, python: 3.6, dicom2nifti2.3.0
Where am I doing wrong?
Or is there any other way to convert it?
Thanks in advance!
I haven't used dicom2nifti, but you can convert DICOM to Nifti using SimpleITK.
Here's the code that ought to do the job:
import SimpleITK as sitk
reader = sitk.ImageSeriesReader()
dicom_names = reader.GetGDCMSeriesFileNames('M0_1')
reader.SetFileNames(dicom_names)
image = reader.Execute()
# Added a call to PermuteAxes to change the axes of the data
image = sitk.PermuteAxes(image, [2, 1, 0])
sitk.WriteImage(image, 'M0_1.nii.gz')
You can learn more about SimpleITK here: https://simpleitk.readthedocs.io/
UPDATE: I added a call to SimpleITK's PermuteAxes to change the axis order from X-Y-Z to Z-Y-X.

KeyError: 'CUDA_VISIBLE_DEVICES'

today I asked this question concerning problems with PyTorch running on my GPU. In response, someone kindly suggested running the following code:
import os
num_gpus = os.environ['CUDA_VISIBLE_DEVICES'].split(',').__len__()
os.environ['CUDA_VISIBLE_DEVICES'] = ','.join(f'{i}' for i in range(num_gpus))
However, after running that second line, unfortunately I get another error:
num_gpus = os.environ['CUDA_VISIBLE_DEVICES'].split(',').__len__()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/hbp/anaconda3/lib/python3.8/os.py", line 675, in __getitem__
raise KeyError(key) from None
KeyError: 'CUDA_VISIBLE_DEVICES'
I tried to look it up, but couldn't find anything helpful.
Does anyone have an idea what I could try? The question I linked to may have relevant info.

Index Error while trying to run a neural network

I am new to both python and neural networks.
I am trying to run this
First I did
sh ./create_dataset.sh
And gave the correct path to scenflow_data_path.
Now I am trying to run this:
python main.py --maxdisp 192 --with_spn
as given, I am getting this following error. Please let me know how to correct this.
The error is:
Traceback (most recent call last):
File "main.py", line 194, in <module>
main()
File "main.py", line 51, in main
args.datapath)
File "/home/kbdp5524/Downloads/AnyNet-master/dataloader/listflowfile.py", line 23, in dataloader
monkaa_path = filepath + [x for x in image if 'monkaa' in x][0]
IndexError: list index out of range

ValueError: error during iteration "Pysam"

I have ran into this error and I am having trouble resolving it. Here is it what I get:
Traceback (most recent call last):
File "afile.py", line 100, in <module>
for col in bam.pileup( chrm, ps1, ps1+1,truncate=True):
File "pysam/calignmentfile.pyx", line 2060, in pysam.calignmentfile.IteratorColumnRegion.__next__
(pysam/calignmentfile.c:23305)
ValueError: error during iteration
Thanks a lot in advance.
i hit this recently. the root cause in my case was that the .bai bam index file was out of date. after i regenerated it with samtools index XXX.bam, the pysam crash went away.

Cannot determine type of file

Hi i have just started learning image processing using python.
When i tried to open an image that i downloaded from the net, I keep getting this error and I have no idea about how to resolve it. Can anyone please help me with this?
>>> dna=mahotas.imread('dna.jpeg')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\mahotas\io\freeimage.py", line 773, in imread
img = read(filename)
File "C:\Python27\lib\site-packages\mahotas\io\freeimage.py", line 444, in read
bitmap = _read_bitmap(filename, flags)
File "C:\Python27\lib\site-packages\mahotas\io\freeimage.py", line 490, in _read_bitmap
'mahotas.freeimage: cannot determine type of file %s' % filename)
ValueError: mahotas.freeimage: cannot determine type of file dna.jpeg
Hello this looks like a pretty old thread but I found it recently because I had the same problem.
I think that the error message is misleading because it implies that the type of file is incorrect.
I fixed the problem by including the full path to the image file. For example, it could look something like:
dna = mahotas.imread('C:\Documents\dna.jpeg')

Categories