Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8079701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:11:36+00:00 2026-06-05T16:11:36+00:00

I am using a script which generate a collection of strings in a loop:

  • 0

I am using a script which generate a collection of strings in a loop:

'folder1/im1' 
'folder1/im2'
... 
'folder1/im3'

I assign the string to a variable, when I try to execute the img = dicomread(file); function I get the following error:

Error using dicomread>newDicomread (line 164)
The first input argument must be a filename or DICOM info struct.

Error in dicomread (line 80)
[X, map, alpha, overlays] = newDicomread(msgname, frames);

Error in time (line 14)
    img = dicomread(file);

However, using the command line I don’t get errors: img = dicomread('folder1/im1').

The code is the next:

    for i=1:6 %six cases
            nameDir = strcat('folder', int2str(i));
            dirData = dir(nameDir);
            dirIndex = [dirData.isdir];
            fileList = {dirData(~dirIndex).name}; % list of files for each directory
            n = size(fileList);
            cd(nameDir);
            for x = 1:n(2)
                    img = dicomread(strcat(pwd(), '/', fileList(x)));
            end
            cd('..');
    end

What could be the error?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T16:11:38+00:00Added an answer on June 5, 2026 at 4:11 pm

    You’ve figured it out by now, haven’t you.

    Based on what you’ve written, you test

    img = dicomread('folder1/im1');
    

    when what you are having trouble with is

    img = dicomread(file);
    

    You need to actually test the line you are having trouble with. I would recommend:

    putting a break point in test.m a the line img = dicomread(file). When you get to that line you can see what file is equal to. Also do whos file to make sure it is of class char and not a cell array or something random.

    If you still want help, edit your original post and show the code where you assign those strings to file and tell us what happens when you type img = dicomread(file) at the command prompt.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to generate an HTML file using a PHP script which
the following is a script which was generated using generate script option. the wizard
I'm using this script which works fine for a single lightbox popup window. I
I am rebuilding indexes using a script which reorganises or rebuilds indexes according to
I'm not sure how simple this would be, but I'm using a script which
I'm using simple gallery script which dynamically loads image when user clicks on thumbnail
I am using a Perl script which deletes the data from mqueue folder for
I'm currently using the below script which I found online: ######################################### #### BEGIN EDIT
I have a small script which im using to test PHP mail(), as below:
I am using a bespoke JQuery/PHP script which parses a Flickr feed using SimpliePie

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.